Skip to content

Commit

Permalink
Fix: make File(Like?)[Symbol.toStringTag] a getter (#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojpawlik committed Nov 27, 2021
1 parent 039354b commit 201343c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/fetch/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ class File extends Blob {
return this[kState].lastModified
}

[Symbol.toStringTag] () {
if (!(this instanceof File)) {
throw new TypeError('Illegal invocation')
}

get [Symbol.toStringTag] () {
return 'File'
}
}
Expand Down Expand Up @@ -162,11 +158,7 @@ class FileLike {
return this[kState].lastModified
}

[Symbol.toStringTag] () {
if (!(this instanceof FileLike)) {
throw new TypeError('Illegal invocation')
}

get [Symbol.toStringTag] () {
return 'File'
}
}
Expand Down
10 changes: 10 additions & 0 deletions test/fetch/file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict'

const { test } = require('tap')
const { File, FileLike } = require('../../lib/fetch/file')

test('Symbol.toStringTag', (t) => {
t.plan(2)
t.equal(File.prototype[Symbol.toStringTag], 'File')
t.equal(FileLike.prototype[Symbol.toStringTag], 'File')
})

0 comments on commit 201343c

Please sign in to comment.