From f248e6f1778dc26db91d3322de2ecca5d1aa9866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 27 Jan 2022 16:27:22 +0100 Subject: Revert "refactor: update runtime code for primordial checks for "instanceof" (#13497)" (#13511) This reverts commit 884143218fad0e18f7553aaf079d52de703f7601. --- ext/webidl/00_webidl.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'ext/webidl/00_webidl.js') diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js index de3221081..668c141cb 100644 --- a/ext/webidl/00_webidl.js +++ b/ext/webidl/00_webidl.js @@ -11,7 +11,7 @@ ((window) => { const core = window.Deno.core; const { - ArrayBufferPrototype, + ArrayBuffer, ArrayBufferIsView, ArrayPrototypeForEach, ArrayPrototypePush, @@ -20,6 +20,7 @@ BigInt, BigIntAsIntN, BigIntAsUintN, + DataView, Float32Array, Float64Array, FunctionPrototypeBind, @@ -49,7 +50,6 @@ ObjectGetOwnPropertyDescriptors, ObjectGetPrototypeOf, ObjectPrototypeHasOwnProperty, - ObjectPrototypeIsPrototypeOf, ObjectIs, PromisePrototypeThen, PromiseReject, @@ -434,11 +434,11 @@ } function isNonSharedArrayBuffer(V) { - return ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V); + return V instanceof ArrayBuffer; } function isSharedArrayBuffer(V) { - return ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V); + return V instanceof SharedArrayBuffer; } converters.ArrayBuffer = (V, opts = {}) => { @@ -457,7 +457,7 @@ }; converters.DataView = (V, opts = {}) => { - if (!(ObjectPrototypeIsPrototypeOf(DataViewPrototype, V))) { + if (!(V instanceof DataView)) { throw makeException(TypeError, "is not a DataView", opts); } @@ -862,7 +862,7 @@ function createInterfaceConverter(name, prototype) { return (V, opts) => { - if (!ObjectPrototypeIsPrototypeOf(prototype, V) || V[brand] !== brand) { + if (!(V instanceof prototype) || V[brand] !== brand) { throw makeException(TypeError, `is not of type ${name}.`, opts); } return V; @@ -877,9 +877,7 @@ } function assertBranded(self, prototype) { - if ( - !ObjectPrototypeIsPrototypeOf(prototype, self) || self[brand] !== brand - ) { + if (!(self instanceof prototype) || self[brand] !== brand) { throw new TypeError("Illegal invocation"); } } @@ -946,7 +944,7 @@ } function entries() { - assertBranded(this, prototype.prototype); + assertBranded(this, prototype); return createDefaultIterator(this, "key+value"); } @@ -965,7 +963,7 @@ }, keys: { value: function keys() { - assertBranded(this, prototype.prototype); + assertBranded(this, prototype); return createDefaultIterator(this, "key"); }, writable: true, @@ -974,7 +972,7 @@ }, values: { value: function values() { - assertBranded(this, prototype.prototype); + assertBranded(this, prototype); return createDefaultIterator(this, "value"); }, writable: true, @@ -983,7 +981,7 @@ }, forEach: { value: function forEach(idlCallback, thisArg = undefined) { - assertBranded(this, prototype.prototype); + assertBranded(this, prototype); const prefix = `Failed to execute 'forEach' on '${name}'`; requiredArguments(arguments.length, 1, { prefix }); idlCallback = converters["Function"](idlCallback, { -- cgit v1.2.3