Thursday, August 21st, 2008
querySelectorAll is coming fast
<>p>
We have all been talking about querySelectAll for awhile, but John Resig gives us a wrap-up that covers the state of play.
He talks about the browsers, and the libraries that wrap them and clean up shop via code like:
-
-
-
function querySelectorAll(selector){
-
try {
-
return Array.prototype.slice.call(
-
document.querySelectorAll( selector ) );
-
} catch(e){}
-
-
return myOtherLibrary( selector );
-
}
-
Less code. More speed.
Related Content:











I’ve been wondering what “querySelector” meant since the first time i read it (just ignored it since it sounds boring).
Now i read that it just means getElementsBySelector() whcih immediately tells anyone who ever used getElementById or getElementsByTagNamw what it does.
Why in the world would you use a puzzling name like querySelector in stead of a self-explanatory name like getElementBySelector?
Second that. A “query selector” would be something that selects queries. To be more specific, it only works with CSS selectors. In Hpricot you can use either XPath or CSS selectors, which is much nicer.