Monday, May 11, 2009

Using Sizzle with Prototype

Recently, John Resig of jQuery fame released the selector engine used in the new version of jQuery called Sizzle.
Sizzle is a new take on using CSS selectors within Javascript and aims to be far more efficient than the methods commonly used by most current Javascript libraries.
//Overwrite findChildElements to use Sizzle http://sizzlejs.com
Selector.findChildElements = function(element, expression){
expression = expression.join(", ");
var results = Sizzle(expression, element);
if(results.length > 0){
for(var i=0; i < results.length; i++){
results[i] = Element.extend(results[i]);
}
}
return results;
};
http://briancrescimanno.com/2009/03/24/using-sizzle-with-prototype

No comments: