Syncing Sizzle codebase.

This commit is contained in:
John Resig 2008-12-20 22:45:11 +00:00
parent 6f2f1830a4
commit 6048e40a45

View file

@ -12,7 +12,7 @@ var done = 0;
if ( document.addEventListener && !document.querySelectorAll ) { if ( document.addEventListener && !document.querySelectorAll ) {
cache = {}; cache = {};
function invalidate(){ cache = {}; } var invalidate = function(){ cache = {}; };
document.addEventListener("DOMAttrModified", invalidate, false); document.addEventListener("DOMAttrModified", invalidate, false);
document.addEventListener("DOMNodeInserted", invalidate, false); document.addEventListener("DOMNodeInserted", invalidate, false);
document.addEventListener("DOMNodeRemoved", invalidate, false); document.addEventListener("DOMNodeRemoved", invalidate, false);
@ -59,24 +59,24 @@ var Sizzle = function(selector, context, results, seed) {
selector = selector.replace( Expr.match.POS, "" ); selector = selector.replace( Expr.match.POS, "" );
} }
checkSet = Sizzle.filter( later, Sizzle( selector, context, results ) ); set = Sizzle.filter( later, Sizzle( selector, context ) );
} else { } else {
checkSet = Expr.relative[ parts[0] ] ? set = Expr.relative[ parts[0] ] ?
[ context ] : [ context ] :
Sizzle( parts.shift(), context ); Sizzle( parts.shift(), context );
while ( parts.length ) { while ( parts.length ) {
set = []; var tmpSet = [];
selector = parts.shift(); selector = parts.shift();
if ( Expr.relative[ selector ] ) if ( Expr.relative[ selector ] )
selector += parts.shift(); selector += parts.shift();
for ( var i = 0, l = checkSet.length; i < l; i++ ) { for ( var i = 0, l = set.length; i < l; i++ ) {
Sizzle( selector, checkSet[i], set ); Sizzle( selector, set[i], tmpSet );
} }
checkSet = set; set = tmpSet;
} }
} }
} else { } else {
@ -104,10 +104,10 @@ var Sizzle = function(selector, context, results, seed) {
Expr.relative[ cur ]( checkSet, pop ); Expr.relative[ cur ]( checkSet, pop );
} }
}
if ( !checkSet ) { if ( !checkSet ) {
checkSet = set; checkSet = set;
}
} }
if ( !checkSet ) { if ( !checkSet ) {