X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fselector.js;h=b404064a98e2df010f95ed34e6b3976256646b65;hb=e10e625bf4865cb8e9927e94d15afa37f6537a03;hp=e58b2571cbc598f028e7fb97f931402760ad1661;hpb=410e13b40097fa6b26ce9a27f865ff258efa23b4;p=jquery.git diff --git a/src/selector.js b/src/selector.js index e58b257..b404064 100644 --- a/src/selector.js +++ b/src/selector.js @@ -9,9 +9,7 @@ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, done = 0, toString = Object.prototype.toString, - arraySplice = Array.prototype.splice, - arrayPush = Array.prototype.push, - arraySort = Array.prototype.sort; + hasDuplicate = false; var Sizzle = function(selector, context, results, seed) { results = results || []; @@ -107,17 +105,17 @@ var Sizzle = function(selector, context, results, seed) { if ( toString.call(checkSet) === "[object Array]" ) { if ( !prune ) { - arrayPush.apply( results, checkSet ); + results.push.apply( results, checkSet ); } else if ( context && context.nodeType === 1 ) { for ( var i = 0; checkSet[i] != null; i++ ) { if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { - arrayPush.call( results, set[i] ); + results.push( set[i] ); } } } else { for ( var i = 0; checkSet[i] != null; i++ ) { if ( checkSet[i] && checkSet[i].nodeType === 1 ) { - arrayPush.call( results, set[i] ); + results.push( set[i] ); } } } @@ -136,12 +134,12 @@ var Sizzle = function(selector, context, results, seed) { Sizzle.uniqueSort = function(results){ if ( sortOrder ) { hasDuplicate = false; - arraySort.call(results, sortOrder); + results.sort(sortOrder); if ( hasDuplicate ) { for ( var i = 1; i < results.length; i++ ) { if ( results[i] === results[i-1] ) { - arraySplice.call(results, i--, 1); + results.splice(i--, 1); } } } @@ -659,14 +657,14 @@ var Expr = Sizzle.selectors = { var origPOS = Expr.match.POS; for ( var type in Expr.match ) { - Expr.match[ type ] = RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); } var makeArray = function(array, results) { array = Array.prototype.slice.call( array ); if ( results ) { - arrayPush.apply( results, array ); + results.push.apply( results, array ); return results; } @@ -738,9 +736,9 @@ if ( document.documentElement.compareDocumentPosition ) { // querying by getElementById (and provide a workaround) (function(){ // We're going to inject a fake input element with a specified name - var form = document.createElement("form"), + var form = document.createElement("div"), id = "script" + (new Date).getTime(); - form.innerHTML = ""; + form.innerHTML = ""; // Inject it into the root element, check its status, and remove it quickly var root = document.documentElement; @@ -763,6 +761,7 @@ if ( document.documentElement.compareDocumentPosition ) { } root.removeChild( form ); + root = form = null; // release memory in IE })(); (function(){ @@ -803,6 +802,8 @@ if ( document.documentElement.compareDocumentPosition ) { return elem.getAttribute("href", 2); }; } + + div = null; // release memory in IE })(); if ( document.querySelectorAll ) (function(){ @@ -829,10 +830,11 @@ if ( document.querySelectorAll ) (function(){ return oldSizzle(query, context, extra, seed); }; - Sizzle.find = oldSizzle.find; - Sizzle.filter = oldSizzle.filter; - Sizzle.selectors = oldSizzle.selectors; - Sizzle.matches = oldSizzle.matches; + for ( var prop in oldSizzle ) { + Sizzle[ prop ] = oldSizzle[ prop ]; + } + + div = null; // release memory in IE })(); if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ @@ -855,6 +857,8 @@ if ( document.getElementsByClassName && document.documentElement.getElementsByCl return context.getElementsByClassName(match[1]); } }; + + div = null; // release memory in IE })(); function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { @@ -973,7 +977,7 @@ jQuery.expr = Sizzle.selectors; jQuery.expr[":"] = jQuery.expr.filters; Sizzle.selectors.filters.hidden = function(elem){ - return elem.offsetWidth === 0 || elem.offsetHeight === 0; + return elem.offsetWidth === 0 && elem.offsetHeight === 0; }; Sizzle.selectors.filters.visible = function(elem){