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

Kornel Lesiński kornel at geekhood.net
Sat Jan 4 07:10:22 PST 2014


Everywhere on the web where NodeList.forEach() is mentioned, everybody  
agrees that's something that is expected to work, but doesn't. It's  
followed by a list of excuses why it doesn't work, as if it was a  
completely intractable problem that nobody can ever fix in any way  
whatsoever.

Can we please switch efforts from explaining why it's broken to actually  
fixing it?


It's sad that I can't use  
document.querySelector().filter().map().forEach() without patching  
prototypes myself. ES6 Array.from(), even with syntactic sugar, is a  
band-aid. NodeList.forEach() still doesn't work, but should.


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);
}

etc.

-- 
regards, Kornel Lesiński


More information about the whatwg mailing list