mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
refactor(runtime): Use util.nonEnumerable
to define console
(#11982)
A comment in `runtime.js` reads that `console` seems to be "the only one that should be writable and non-enumerable", which explains why it is declared with `util.writable` but then has its property descriptor's `enumerable` key changed to false. But it is not in fact true that `console` is the only global property for which this holds, and it wasn't even when this behavior was introduced in denoland#9013. All WebIDL interfaces are also writable and non-enumerable – the only difference here being that `console` is a namespace rather than an interface. Since WebIDL interfaces are defined with `util.nonEnumerable`, and `console` uses the same descriptor keys, this PR changes the definition of `console` to use `util.nonEnumerable` as well.
This commit is contained in:
parent
0cb22d4cba
commit
676565c711
1 changed files with 1 additions and 6 deletions
|
@ -418,7 +418,7 @@ delete Object.prototype.__proto__;
|
|||
btoa: util.writable(base64.btoa),
|
||||
clearInterval: util.writable(timers.clearInterval),
|
||||
clearTimeout: util.writable(timers.clearTimeout),
|
||||
console: util.writable(
|
||||
console: util.nonEnumerable(
|
||||
new Console((msg, level) => core.print(msg, level > 1)),
|
||||
),
|
||||
crypto: util.readOnly(crypto.crypto),
|
||||
|
@ -468,11 +468,6 @@ delete Object.prototype.__proto__;
|
|||
GPUValidationError: util.nonEnumerable(webgpu.GPUValidationError),
|
||||
};
|
||||
|
||||
// The console seems to be the only one that should be writable and non-enumerable
|
||||
// thus we don't have a unique helper for it. If other properties follow the same
|
||||
// structure, it might be worth it to define a helper in `util`
|
||||
windowOrWorkerGlobalScope.console.enumerable = false;
|
||||
|
||||
const mainRuntimeGlobalProperties = {
|
||||
Location: location.locationConstructorDescriptor,
|
||||
location: location.locationDescriptor,
|
||||
|
|
Loading…
Reference in a new issue