Hacker News new | ask | show | jobs
by antoineMoPa 3620 days ago
I like the fact that it works with querySelectorAll! This is compatible with my projects in which I do:

    var qsa = function(sel){return document.querySelectorAll(sel)};
However, it does not work with:

    var subqsa = function(el,sel){return el.querySelectorAll(sel);}
2 comments

If you're seriously wondering why is it so then, well, they're just replacing native methods of the document object, in order to get the same behavior from your second line, they'll have to replace Element.prototype.querySelectorAll as well, which is a bad idea.
You can just:

  var queryAll = document.querySelectorAll.bind(document);