From 0b8d8e3e08132a109010c91c5e0bdf8e760c0ba1 Mon Sep 17 00:00:00 2001 From: uzlopak Date: Thu, 1 Feb 2024 07:53:05 +0100 Subject: [PATCH] fix: webidl.brandcheck non strict should throw --- lib/fetch/webidl.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/fetch/webidl.js b/lib/fetch/webidl.js index cb6bcc37db9..9ee7c4fe569 100644 --- a/lib/fetch/webidl.js +++ b/lib/fetch/webidl.js @@ -34,10 +34,14 @@ webidl.errors.invalidArgument = function (context) { // https://webidl.spec.whatwg.org/#implements webidl.brandCheck = function (V, I, opts = undefined) { - if (opts?.strict !== false && !(V instanceof I)) { - throw new TypeError('Illegal invocation') + if (opts?.strict !== false) { + if (!(V instanceof I)) { + throw new TypeError('Illegal invocation') + } } else { - return V?.[Symbol.toStringTag] === I.prototype[Symbol.toStringTag] + if (V?.[Symbol.toStringTag] === I.prototype[Symbol.toStringTag]) { + throw new TypeError('Illegal invocation') + } } }