-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent enumerability #20565
Comments
timers are enumerable by spec and most if not all of the whatwg globals are unenumerable by spec |
I know about timers and the whatwg ones. But that still leaves:
|
See #10405 for I think we could close this issue. |
what spec? AFAIK we don't have a spec. |
Honestly I think there isn't a lot of value and there is a lot of breakage potential in making things enumerable/not-enumerable. I think we should have a "new things are not enumerable" policy overall - and that anyone doing |
https://html.spec.whatwg.org/ - timers (and over 200 other window properties) are enumerable. |
Chromium 66.0.3359.139 output for comparison: > Object.keys(window).filter(x => !/^(on|webkit|screen|page|scroll)/.test(x)).sort()
(75) [ "alert", "applicationCache", "atob", "blur", "btoa", "cancelAnimationFrame",
"cancelIdleCallback", "captureEvents", "chrome", "clearInterval", "clearTimeout",
"clientInformation", "close", "closed", "confirm", "createImageBitmap", "crypto",
"customElements", "defaultStatus", "defaultstatus", "devicePixelRatio", "document",
"external", "fetch", "find", "focus", "frameElement", "frames", "getComputedStyle",
"getSelection", "history", "indexedDB", "innerHeight", "innerWidth", "isSecureContext",
"length", "localStorage", "location", "locationbar", "matchMedia", "menubar", "moveBy",
"moveTo", "name", "navigator", "open", "openDatabase", "opener", "origin", "outerHeight",
"outerWidth", "parent", "performance", "personalbar", "postMessage", "print", "prompt",
"releaseEvents", "requestAnimationFrame", "requestIdleCallback", "resizeBy", "resizeTo",
"self", "sessionStorage", "setInterval", "setTimeout", "speechSynthesis", "status",
"statusbar", "stop", "styleMedia", "toolbar", "top", "visualViewport", "window" ] |
We don't follow that spec at all though, not with regards to limits, edge cases, return values and so on. If we want to consider following the DOM timer spec then we should probably work towards those goals. I'm a maintainer in a fake timer library and there is quite a bit of code that deals with differences between Node and browsers :) |
|
It seems like perhaps this should be closed, as the remaining items are debatable? Feel free to re-open (or leave a comment requesting that it be re-opened) if you disagree (or open a PR). I'm just tidying up and not acting on a super-strong opinion or anything like that. |
This makes sure these two properties are non-enumerable. This aligns them with all other globals that are not enumerable by spec. Refs: nodejs#20565
This makes sure these two properties are non-enumerable. This aligns them with all other globals that are not enumerable by spec. Refs: nodejs#20565 PR-URL: nodejs#24874 Refs: nodejs#20565 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This makes sure these two properties are non-enumerable. This aligns them with all other globals that are not enumerable by spec. Refs: nodejs#20565 PR-URL: nodejs#24874 Refs: nodejs#20565 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
When looking at the
global
object we have quite a few properties that are not enumerable and we have a couple that are.Using
Object.keys(global)
currently results in:URL
andconsole
are for example not enumerable. Should we maybe reconsider these and either set everything to being enumerable / not enumerable? Or should we just define that everything added from now will be not enumerable?I could also not find any issue that was directly about this before. Somewhat related: #8810
The text was updated successfully, but these errors were encountered: