The one I hate most is that qSA returns Yet Another JavaScript Collection That Is A Lot Like An Array But Isn't An Array And Therefore Doesn't Have Any Of The Nice Methods(TM). Yes, you're going to have to iterate over the thing using an index in a loop.
There's others:
http://ejohn.org/blog/thoughts-on-queryselectorall/
I'm really not sure how the standards-makers got this so terribly wrong given that the libraries had already started to solve the problem.
Array.prototype.slice.call(document.querySelectorAll('.myClass'), 0);
Or if you want to abstract that into a utility function: function qsa(sel) {
return Array.prototype.slice.call(document.querySelectorAll(sel), 0);
}
qsa('.myClass'); // Returns array of elementsAdd a few more helper functions, separate it all out to its own js file, reuse the js file in other projects, and soon people will complain about the bloated js file you keep using in your projects.
Man, I really do enjoy my chosen line of work. It creates such fun things to debate over.
http://dom.spec.whatwg.org/#elements
But AFAICT isn't implemented anywhere, which makes it not that useful. Perhaps a polyfill could be done.