Bug 152454
| Summary: | Object.keys returns length property of some DOM Objects | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Felquis <oi> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED CONFIGURATION CHANGED | ||
| Severity: | Trivial | CC: | ahmad.saleem792, ap, bfulgham, cdumez, rniwa |
| Priority: | P2 | ||
| Version: | Safari 9 | ||
| Hardware: | Mac | ||
| OS: | OS X 10.10 | ||
Felquis
Hello
Object.keys(document.styleSheets) returns ['0', 'length'] while other browsers returns ['0']..
Object.keys(document.querySelectorAll('div')) also returns the 'length' as a key.. but in Chrome, Firefox and Opera does not. So I think it is a Safari issue.
Tested into Version 9.0.2 (10601.3.9), may affect iOS and probably affect others DOM Object TokenLists and Collections, for example HTMLCollection `Object.keys(document.body.children)` also returns the length property...
It is breaking my code here https://github.com/felquis/CSSOM-Query/issues/1
Thanks..
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Ahmad Saleem
I am able to reproduce this issue while running these two in console on this page in Safari 15.6 on macOS 12.5 and other browsers:
*** Safari 15.6 on macOS 12.5 ***
For Object.keys(document.styleSheets); - it returns ["0", "1", "2"] (3)
For Object.keys(document.querySelectorAll('div')); - it returns ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", …] (38)
*** Firefox Nightly 105 & Chrome Canary 106 ***
For first - (2) ['0', '1']
For second - (16) ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15']
____
If I am testing wrong then please ignore me but just wanted to share updated results. Thanks!
Ryosuke Niwa
Not reproducing this anymore. We likely fixed it in recent bindings improvements.