1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

fix(ext/web): use Array primordials in MessagePort (#11680)

This commit is contained in:
Divy Srivastava 2021-08-13 13:43:46 +05:30 committed by GitHub
parent 5d6d6836bb
commit 8481377500
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,6 +15,8 @@
const { defineEventHandler } = window.__bootstrap.event;
const { DOMException } = window.__bootstrap.domException;
const {
ArrayPrototypeIncludes,
ArrayPrototypePush,
ObjectSetPrototypeOf,
Symbol,
SymbolFor,
@ -117,7 +119,7 @@
);
}
const { transfer } = options;
if (transfer.includes(this)) {
if (ArrayPrototypeIncludes(transfer, this)) {
throw new DOMException("Can not tranfer self", "DataCloneError");
}
const data = serializeJsMessageData(message, transfer);
@ -196,7 +198,7 @@
switch (transferable.kind) {
case "messagePort": {
const port = createMessagePort(transferable.data);
transferables.push(port);
ArrayPrototypePush(transferables, port);
break;
}
default:
@ -238,7 +240,10 @@
);
}
transferable[_id] = null;
serializedTransferables.push({ kind: "messagePort", data: id });
ArrayPrototypePush(serializedTransferables, {
kind: "messagePort",
data: id,
});
} else {
throw new DOMException("Value not transferable", "DataCloneError");
}