refactor(runtime): Use util.nonEnumerable
to define console
#11982
+1
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
refactor(runtime): Use
util.nonEnumerable
to defineconsole
A comment in
runtime.js
reads thatconsole
seems to be "the only one that should be writable and non-enumerable", which explains why it is declared withutil.writable
but then has its property descriptor'senumerable
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 #9013. All WebIDL interfaces are also writable and non-enumerable – the only difference here being thatconsole
is a namespace rather than an interface.Since WebIDL interfaces are defined with
util.nonEnumerable
, andconsole
uses the same descriptor keys, this PR changes the definition ofconsole
to useutil.nonEnumerable
as well.Here's the original commit message:
A comment in
runtime.js
reads thatconsole
seems to be "the only one that should be writable and non-enumerable", which explains why it is declared withutil.writable
to then have the property descriptor'senumerable
key changed to false.That is not in fact true, and it wasn't even in #9013, when that behavior was introduced. In fact all WebIDL interfaces are writable and non-enumerable, declared with
util.nonEnumerable
– the difference here being thatconsole
is a namespace / object.WebIDL, however, treats namespaces and interfaces similarly, and defines them with the same descriptor keys, so this PR changes the definition of
console
to useutil.nonEnumerable
.