1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

fix: Support Symbol.metadata (#22282)

This commit adds support for "Symbol.metadata" which was 
omitted when adding support for the Decorators Proposal.

Closes https://github.com/denoland/deno/issues/22111
This commit is contained in:
Bartek Iwańczuk 2024-02-06 14:57:25 +01:00 committed by GitHub
parent e568cb8bf8
commit 7c111da5f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 34 additions and 1 deletions

View file

@ -84,6 +84,7 @@ util::unit_test_factory!(
stdio_test,
streams_test,
structured_clone_test,
symbol_test,
symlink_test,
sync_test,
test_util,

View file

@ -0,0 +1,11 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assert } from "./test_util.ts";
// Test that `Symbol.metadata` is defined. This file can be removed when V8
// supports `Symbol.metadata` natively.
Deno.test(
function symbolMetadataIsDefined() {
assert(typeof Symbol.metadata === "symbol");
},
);

View file

@ -463,6 +463,9 @@ export const SymbolDispose = Symbol.dispose ?? Symbol("Symbol.dispose");
// deno-lint-ignore prefer-primordials
export const SymbolAsyncDispose = Symbol.asyncDispose ??
Symbol("Symbol.asyncDispose");
// deno-lint-ignore prefer-primordials
export const SymbolMetadata = Symbol.metadata ??
Symbol("Symbol.metadata");
export {
ASCII_ALPHA,

View file

@ -89,9 +89,21 @@ import {
import {
workerRuntimeGlobalProperties,
} from "ext:runtime/98_global_scope_worker.js";
import { SymbolAsyncDispose, SymbolDispose } from "ext:deno_web/00_infra.js";
import {
SymbolAsyncDispose,
SymbolDispose,
SymbolMetadata,
} from "ext:deno_web/00_infra.js";
// deno-lint-ignore prefer-primordials
if (Symbol.dispose) throw "V8 supports Symbol.dispose now, no need to shim it!";
// deno-lint-ignore prefer-primordials
if (Symbol.asyncDispose) {
throw "V8 supports Symbol.asyncDispose now, no need to shim it!";
}
// deno-lint-ignore prefer-primordials
if (Symbol.metadata) {
throw "V8 supports Symbol.metadata now, no need to shim it!";
}
ObjectDefineProperties(Symbol, {
dispose: {
value: SymbolDispose,
@ -105,6 +117,12 @@ ObjectDefineProperties(Symbol, {
writable: false,
configurable: false,
},
metadata: {
value: SymbolMetadata,
enumerable: false,
writable: false,
configurable: false,
},
});
let windowIsClosing = false;