[whatwg] NodeList.forEach/map/filter still doesn't work

David Bruant bruant.d at gmail.com
Sat Jan 4 10:17:02 PST 2014


Le 04/01/2014 16:10, Kornel Lesiński a écrit :
> I don't think anybody cares for NodeList.forEach/map/filter/etc to be 
> "real" Array functions, so I'd love to see even a simplest fix like:
>
> NodeList.prototype.map = function(...whatever) {
>     return Array.from(this).map(...whatever);
> }
>
> NodeList.prototype.forEach = function(...whatever) {
>     return Array.from(this).forEach(...whatever);
> }
No need. Array.prototype.forEach&friends are generic on purpose so they 
can be applied to array-likes like NodeList.
Technically, we can have NodeList.prototype.forEach = 
Array.prototype.forEach (or rather Array.prototype in the NodeList 
instances prototype chain as currently speculatively spec'ed)
I imagine the problem if there is one will be a web compatibility one... 
as usual.

Relevant:
http://dom.spec.whatwg.org/#nodelist
http://code.google.com/p/chromium/issues/detail?id=229398
https://bugzilla.mozilla.org/show_bug.cgi?id=869376

Both Firefox and Chrome are already open to experiment it.
I imagine the only thing they need is the engineering time both to 
implement it and keep an eye open on their bug tracker to see if a 
website breaks because of this change, analyse, revert, do some 
evangelism to broken websites, retry, report back to standards for the 
bad news when people doing the experiment get tired of it.

I wish they were spending the time too. Other people would prefer to see 
the implementation of WebComponents prioritized.

How is your C++ and more importantly, what's the amount of time and 
patience you can put on evangelism? ;-)

David



More information about the whatwg mailing list