NodeList.prototype.forEach is non-standard and should not exist
Reported by
fer...@gmail.com,
Sep 16 2016
|
||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.113 Safari/537.36 Steps to reproduce the problem: Chrome should not define `NodeList.prototype.forEach`. As far as I can tell since it's non-standard and does not exist in other browsers. Weirdly, other Array.prototype methods like map() are not defined on NodeList.prototype, only forEach(). I was just bitten by writing code like this: document.querySelectorAll().forEach(...) which only works in Chrome, but not in other browsers like Firefox, etc. What is the expected behavior? NodeList.prototype.forEach should not be defined. What went wrong? NodeList.prototype.forEach exists. Did this work before? Yes Not sure Chrome version: 53.0.2785.113 Channel: n/a OS Version: OS X 10.11.6 Flash Version: Shockwave Flash 23.0 r0 Apologies if I'm missing something obvious here.
,
Sep 16 2016
This is per-spec. NodeList is marked as iterable<Node> [1]. Per Web IDL, this means it gets a forEach method and @@iterator symbol [2], as well as entries, keys, values, [3]. [1]: https://dom.spec.whatwg.org/#interface-nodelist [2]: https://heycam.github.io/webidl/#es-iterators [3]: https://heycam.github.io/webidl/#es-iterable
,
Sep 16 2016
Interesting. I thought iterables just needed a .length and numerical indices. Thanks for clarifying. |
||
►
Sign in to add a comment |
||
Comment 1 by fer...@gmail.com
, Sep 16 2016