diff options
Diffstat (limited to 'ext/web/02_structured_clone.js')
-rw-r--r-- | ext/web/02_structured_clone.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/web/02_structured_clone.js b/ext/web/02_structured_clone.js index 005b668af..058390cfe 100644 --- a/ext/web/02_structured_clone.js +++ b/ext/web/02_structured_clone.js @@ -13,10 +13,12 @@ const { DOMException } = window.__bootstrap.domException; const { ArrayBuffer, + ArrayBufferPrototype, ArrayBufferIsView, - DataView, + DataViewPrototype, + ObjectPrototypeIsPrototypeOf, TypedArrayPrototypeSlice, - TypeError, + TypeErrorPrototype, WeakMap, WeakMapPrototypeSet, } = window.__bootstrap.primordials; @@ -42,7 +44,7 @@ function structuredClone(value) { // Performance optimization for buffers, otherwise // `serialize/deserialize` will allocate new buffer. - if (value instanceof ArrayBuffer) { + if (ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, value)) { const cloned = cloneArrayBuffer( value, 0, @@ -59,7 +61,7 @@ // only DataView has a length in bytes and TypedArrays use a length in // terms of elements, so we adjust for that. let length; - if (value instanceof DataView) { + if (ObjectPrototypeIsPrototypeOf(DataViewPrototype, view)) { length = value.byteLength; } else { length = value.length; @@ -74,7 +76,7 @@ try { return core.deserialize(core.serialize(value)); } catch (e) { - if (e instanceof TypeError) { + if (ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e)) { throw new DOMException("Uncloneable value", "DataCloneError"); } throw e; |