summaryrefslogtreecommitdiff
path: root/ext/webidl/00_webidl.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-02-01 18:06:11 +0100
committerGitHub <noreply@github.com>2022-02-01 18:06:11 +0100
commit8176a4d1663529fb8aeebf7734c4994fa1d583f4 (patch)
tree94c7d6eb2679e641f59cf78640340f5b7af0022e /ext/webidl/00_webidl.js
parentabf89f8c4675ed78c992fafd6d758bf4bfca8a1a (diff)
refactor: primordials for instanceof (#13527)
Diffstat (limited to 'ext/webidl/00_webidl.js')
-rw-r--r--ext/webidl/00_webidl.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js
index 668c141cb..de3221081 100644
--- a/ext/webidl/00_webidl.js
+++ b/ext/webidl/00_webidl.js
@@ -11,7 +11,7 @@
((window) => {
const core = window.Deno.core;
const {
- ArrayBuffer,
+ ArrayBufferPrototype,
ArrayBufferIsView,
ArrayPrototypeForEach,
ArrayPrototypePush,
@@ -20,7 +20,6 @@
BigInt,
BigIntAsIntN,
BigIntAsUintN,
- DataView,
Float32Array,
Float64Array,
FunctionPrototypeBind,
@@ -50,6 +49,7 @@
ObjectGetOwnPropertyDescriptors,
ObjectGetPrototypeOf,
ObjectPrototypeHasOwnProperty,
+ ObjectPrototypeIsPrototypeOf,
ObjectIs,
PromisePrototypeThen,
PromiseReject,
@@ -434,11 +434,11 @@
}
function isNonSharedArrayBuffer(V) {
- return V instanceof ArrayBuffer;
+ return ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V);
}
function isSharedArrayBuffer(V) {
- return V instanceof SharedArrayBuffer;
+ return ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V);
}
converters.ArrayBuffer = (V, opts = {}) => {
@@ -457,7 +457,7 @@
};
converters.DataView = (V, opts = {}) => {
- if (!(V instanceof DataView)) {
+ if (!(ObjectPrototypeIsPrototypeOf(DataViewPrototype, V))) {
throw makeException(TypeError, "is not a DataView", opts);
}
@@ -862,7 +862,7 @@
function createInterfaceConverter(name, prototype) {
return (V, opts) => {
- if (!(V instanceof prototype) || V[brand] !== brand) {
+ if (!ObjectPrototypeIsPrototypeOf(prototype, V) || V[brand] !== brand) {
throw makeException(TypeError, `is not of type ${name}.`, opts);
}
return V;
@@ -877,7 +877,9 @@
}
function assertBranded(self, prototype) {
- if (!(self instanceof prototype) || self[brand] !== brand) {
+ if (
+ !ObjectPrototypeIsPrototypeOf(prototype, self) || self[brand] !== brand
+ ) {
throw new TypeError("Illegal invocation");
}
}
@@ -944,7 +946,7 @@
}
function entries() {
- assertBranded(this, prototype);
+ assertBranded(this, prototype.prototype);
return createDefaultIterator(this, "key+value");
}
@@ -963,7 +965,7 @@
},
keys: {
value: function keys() {
- assertBranded(this, prototype);
+ assertBranded(this, prototype.prototype);
return createDefaultIterator(this, "key");
},
writable: true,
@@ -972,7 +974,7 @@
},
values: {
value: function values() {
- assertBranded(this, prototype);
+ assertBranded(this, prototype.prototype);
return createDefaultIterator(this, "value");
},
writable: true,
@@ -981,7 +983,7 @@
},
forEach: {
value: function forEach(idlCallback, thisArg = undefined) {
- assertBranded(this, prototype);
+ assertBranded(this, prototype.prototype);
const prefix = `Failed to execute 'forEach' on '${name}'`;
requiredArguments(arguments.length, 1, { prefix });
idlCallback = converters["Function"](idlCallback, {