mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
src: distinguish HTML transferable and cloneable
The HTML structured serialize algorithm treats transferable and
serializable as two different bits. A web platform interface can be
both transferable and serializable.
Splits BaseObject::TransferMode to be able to compose the two bits
and distinguishes the transferable and cloneable.
PR-URL: https://github.com/nodejs/node/pull/47956
Refs: cf13b9b465
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
This commit is contained in:
parent
3205b1936a
commit
38dee8a1c0
37 changed files with 549 additions and 322 deletions
|
@ -32,7 +32,7 @@ const {
|
|||
const { URL } = require('internal/url');
|
||||
|
||||
const {
|
||||
makeTransferable,
|
||||
markTransferMode,
|
||||
kClone,
|
||||
kDeserialize,
|
||||
} = require('internal/worker/js_transferable');
|
||||
|
@ -136,6 +136,8 @@ class Blob {
|
|||
* @constructs {Blob}
|
||||
*/
|
||||
constructor(sources = [], options) {
|
||||
markTransferMode(this, true, false);
|
||||
|
||||
if (sources === null ||
|
||||
typeof sources[SymbolIterator] !== 'function' ||
|
||||
typeof sources === 'string') {
|
||||
|
@ -167,9 +169,6 @@ class Blob {
|
|||
type = `${type}`;
|
||||
this[kType] = RegExpPrototypeExec(disallowedTypeCharacters, type) !== null ?
|
||||
'' : StringPrototypeToLowerCase(type);
|
||||
|
||||
// eslint-disable-next-line no-constructor-return
|
||||
return makeTransferable(this);
|
||||
}
|
||||
|
||||
[kInspect](depth, options) {
|
||||
|
@ -385,16 +384,19 @@ class Blob {
|
|||
}
|
||||
|
||||
function ClonedBlob() {
|
||||
return makeTransferable(ReflectConstruct(function() {}, [], Blob));
|
||||
return ReflectConstruct(function() {
|
||||
markTransferMode(this, true, false);
|
||||
}, [], Blob);
|
||||
}
|
||||
ClonedBlob.prototype[kDeserialize] = () => {};
|
||||
|
||||
function createBlob(handle, length, type = '') {
|
||||
return makeTransferable(ReflectConstruct(function() {
|
||||
return ReflectConstruct(function() {
|
||||
markTransferMode(this, true, false);
|
||||
this[kHandle] = handle;
|
||||
this[kType] = type;
|
||||
this[kLength] = length;
|
||||
}, [], Blob));
|
||||
}, [], Blob);
|
||||
}
|
||||
|
||||
ObjectDefineProperty(Blob.prototype, SymbolToStringTag, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue