Skip to content

Commit 678f0f4

Browse files
committed
fix: webidl.brandcheck non strict should throw
1 parent 0808a72 commit 678f0f4

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/fetch/webidl.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ webidl.errors.invalidArgument = function (context) {
3434

3535
// https://webidl.spec.whatwg.org/#implements
3636
webidl.brandCheck = function (V, I, opts = undefined) {
37-
if (opts?.strict !== false && !(V instanceof I)) {
38-
throw new TypeError('Illegal invocation')
37+
if (opts?.strict !== false) {
38+
if (!(V instanceof I)) {
39+
throw new TypeError('Illegal invocation')
40+
}
3941
} else {
40-
return V?.[Symbol.toStringTag] === I.prototype[Symbol.toStringTag]
42+
if (V?.[Symbol.toStringTag] !== I.prototype[Symbol.toStringTag]) {
43+
throw new TypeError('Illegal invocation')
44+
}
4145
}
4246
}
4347

0 commit comments

Comments
 (0)