mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(ext/web): use Array primordials in MessagePort (#11680)
This commit is contained in:
parent
5d6d6836bb
commit
8481377500
1 changed files with 8 additions and 3 deletions
|
@ -15,6 +15,8 @@
|
||||||
const { defineEventHandler } = window.__bootstrap.event;
|
const { defineEventHandler } = window.__bootstrap.event;
|
||||||
const { DOMException } = window.__bootstrap.domException;
|
const { DOMException } = window.__bootstrap.domException;
|
||||||
const {
|
const {
|
||||||
|
ArrayPrototypeIncludes,
|
||||||
|
ArrayPrototypePush,
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
Symbol,
|
Symbol,
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
|
@ -117,7 +119,7 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const { transfer } = options;
|
const { transfer } = options;
|
||||||
if (transfer.includes(this)) {
|
if (ArrayPrototypeIncludes(transfer, this)) {
|
||||||
throw new DOMException("Can not tranfer self", "DataCloneError");
|
throw new DOMException("Can not tranfer self", "DataCloneError");
|
||||||
}
|
}
|
||||||
const data = serializeJsMessageData(message, transfer);
|
const data = serializeJsMessageData(message, transfer);
|
||||||
|
@ -196,7 +198,7 @@
|
||||||
switch (transferable.kind) {
|
switch (transferable.kind) {
|
||||||
case "messagePort": {
|
case "messagePort": {
|
||||||
const port = createMessagePort(transferable.data);
|
const port = createMessagePort(transferable.data);
|
||||||
transferables.push(port);
|
ArrayPrototypePush(transferables, port);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -238,7 +240,10 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
transferable[_id] = null;
|
transferable[_id] = null;
|
||||||
serializedTransferables.push({ kind: "messagePort", data: id });
|
ArrayPrototypePush(serializedTransferables, {
|
||||||
|
kind: "messagePort",
|
||||||
|
data: id,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
throw new DOMException("Value not transferable", "DataCloneError");
|
throw new DOMException("Value not transferable", "DataCloneError");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue