mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
buffer: add @@toStringTag to Blob
This commit adds the toStringTag to the Blob class to match the behavior of Chrome and Firefox. PR-URL: https://github.com/nodejs/node/pull/37336 Fixes: https://github.com/nodejs/node/issues/37337 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
@@ -2,12 +2,14 @@
|
||||
|
||||
const {
|
||||
ArrayFrom,
|
||||
ObjectDefineProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
PromiseResolve,
|
||||
RegExpPrototypeTest,
|
||||
StringPrototypeToLowerCase,
|
||||
Symbol,
|
||||
SymbolIterator,
|
||||
SymbolToStringTag,
|
||||
Uint8Array,
|
||||
} = primordials;
|
||||
|
||||
@@ -217,6 +219,11 @@ class Blob extends JSTransferable {
|
||||
}
|
||||
}
|
||||
|
||||
ObjectDefineProperty(Blob.prototype, SymbolToStringTag, {
|
||||
configurable: true,
|
||||
value: 'Blob',
|
||||
});
|
||||
|
||||
InternalBlob.prototype.constructor = Blob;
|
||||
ObjectSetPrototypeOf(
|
||||
InternalBlob.prototype,
|
||||
|
||||
@@ -184,3 +184,14 @@ assert.throws(() => new Blob(['test', 1]), {
|
||||
const b = new Blob(['hello'], { type: '\x01' });
|
||||
assert.strictEqual(b.type, '');
|
||||
}
|
||||
|
||||
{
|
||||
const descriptor =
|
||||
Object.getOwnPropertyDescriptor(Blob.prototype, Symbol.toStringTag);
|
||||
assert.deepStrictEqual(descriptor, {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: 'Blob',
|
||||
writable: false
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user