mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -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:
parent
e568cb8bf8
commit
7c111da5f6
4 changed files with 34 additions and 1 deletions
|
@ -84,6 +84,7 @@ util::unit_test_factory!(
|
|||
stdio_test,
|
||||
streams_test,
|
||||
structured_clone_test,
|
||||
symbol_test,
|
||||
symlink_test,
|
||||
sync_test,
|
||||
test_util,
|
||||
|
|
11
cli/tests/unit/symbol_test.ts
Normal file
11
cli/tests/unit/symbol_test.ts
Normal 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");
|
||||
},
|
||||
);
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue