3 ms·
Also: DOM Level 4[1] adds the iterator protocol to NodeList, so soon you won't need that slice.call line. Simply return the result of querySelectorAll ;-) Works
by awalGarg 11y ago
Also: DOM Level 4[1] adds the iterator protocol to NodeList, so soon you won't need that slice.call line. Simply return the result of querySelectorAll ;-) Works in Chrome canary already IIRC.
1: https://www.w3.org/TR/dom/#interface-nodelist https://www.w3.org/TR/dom/#interface-nodelist
- VeejayRampay 11y agoWhy have we had to wait so long though? Who in their right mind thought that it'd be a good idea for NodeList instances to NOT be iterable in the first place? It's almost people writing those specs never use their interfaces for actual work.
- kowdermeister 11y agoI reacted the same way. First I thought 'o yeah, pretty neat' then 'wait, what? it's a collection, but I can't use foreach?' finally arrived at 'ok, I just pull in jQuery again' :)