fix memory leak in IE
This commit is contained in:
parent
c6b59263b5
commit
d72b8307de
|
@ -8,7 +8,8 @@
|
||||||
|
|
||||||
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,
|
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,
|
||||||
done = 0,
|
done = 0,
|
||||||
toString = Object.prototype.toString;
|
toString = Object.prototype.toString,
|
||||||
|
hasDuplicate = false;
|
||||||
|
|
||||||
var Sizzle = function(selector, context, results, seed) {
|
var Sizzle = function(selector, context, results, seed) {
|
||||||
results = results || [];
|
results = results || [];
|
||||||
|
@ -17,19 +18,19 @@ var Sizzle = function(selector, context, results, seed) {
|
||||||
if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
|
if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !selector || typeof selector !== "string" ) {
|
if ( !selector || typeof selector !== "string" ) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context);
|
var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context);
|
||||||
|
|
||||||
// Reset the position of the chunker regexp (start from head)
|
// Reset the position of the chunker regexp (start from head)
|
||||||
chunker.lastIndex = 0;
|
chunker.lastIndex = 0;
|
||||||
|
|
||||||
while ( (m = chunker.exec(selector)) !== null ) {
|
while ( (m = chunker.exec(selector)) !== null ) {
|
||||||
parts.push( m[1] );
|
parts.push( m[1] );
|
||||||
|
|
||||||
if ( m[2] ) {
|
if ( m[2] ) {
|
||||||
extra = RegExp.rightContext;
|
extra = RegExp.rightContext;
|
||||||
break;
|
break;
|
||||||
|
@ -158,7 +159,7 @@ Sizzle.find = function(expr, context, isXML){
|
||||||
|
|
||||||
for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
|
for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
|
||||||
var type = Expr.order[i], match;
|
var type = Expr.order[i], match;
|
||||||
|
|
||||||
if ( (match = Expr.match[ type ].exec( expr )) ) {
|
if ( (match = Expr.match[ type ].exec( expr )) ) {
|
||||||
var left = RegExp.leftContext;
|
var left = RegExp.leftContext;
|
||||||
|
|
||||||
|
@ -420,7 +421,7 @@ var Expr = Sizzle.selectors = {
|
||||||
},
|
},
|
||||||
ATTR: function(match, curLoop, inplace, result, not, isXML){
|
ATTR: function(match, curLoop, inplace, result, not, isXML){
|
||||||
var name = match[1].replace(/\\/g, "");
|
var name = match[1].replace(/\\/g, "");
|
||||||
|
|
||||||
if ( !isXML && Expr.attrMap[name] ) {
|
if ( !isXML && Expr.attrMap[name] ) {
|
||||||
match[1] = Expr.attrMap[name];
|
match[1] = Expr.attrMap[name];
|
||||||
}
|
}
|
||||||
|
@ -446,7 +447,7 @@ var Expr = Sizzle.selectors = {
|
||||||
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
|
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return match;
|
return match;
|
||||||
},
|
},
|
||||||
POS: function(match){
|
POS: function(match){
|
||||||
|
@ -580,20 +581,20 @@ var Expr = Sizzle.selectors = {
|
||||||
if ( first == 1 && last == 0 ) {
|
if ( first == 1 && last == 0 ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var doneName = match[0],
|
var doneName = match[0],
|
||||||
parent = elem.parentNode;
|
parent = elem.parentNode;
|
||||||
|
|
||||||
if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
|
if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
for ( node = parent.firstChild; node; node = node.nextSibling ) {
|
for ( node = parent.firstChild; node; node = node.nextSibling ) {
|
||||||
if ( node.nodeType === 1 ) {
|
if ( node.nodeType === 1 ) {
|
||||||
node.nodeIndex = ++count;
|
node.nodeIndex = ++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent.sizcache = doneName;
|
parent.sizcache = doneName;
|
||||||
}
|
}
|
||||||
|
|
||||||
var diff = elem.nodeIndex - last;
|
var diff = elem.nodeIndex - last;
|
||||||
if ( first == 0 ) {
|
if ( first == 0 ) {
|
||||||
return diff == 0;
|
return diff == 0;
|
||||||
|
@ -666,7 +667,7 @@ var makeArray = function(array, results) {
|
||||||
results.push.apply( results, array );
|
results.push.apply( results, array );
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -760,6 +761,7 @@ if ( document.documentElement.compareDocumentPosition ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
root.removeChild( form );
|
root.removeChild( form );
|
||||||
|
root = form = null; // release memory in IE
|
||||||
})();
|
})();
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
|
@ -800,6 +802,8 @@ if ( document.documentElement.compareDocumentPosition ) {
|
||||||
return elem.getAttribute("href", 2);
|
return elem.getAttribute("href", 2);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div = null; // release memory in IE
|
||||||
})();
|
})();
|
||||||
|
|
||||||
if ( document.querySelectorAll ) (function(){
|
if ( document.querySelectorAll ) (function(){
|
||||||
|
@ -811,7 +815,7 @@ if ( document.querySelectorAll ) (function(){
|
||||||
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
|
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sizzle = function(query, context, extra, seed){
|
Sizzle = function(query, context, extra, seed){
|
||||||
context = context || document;
|
context = context || document;
|
||||||
|
|
||||||
|
@ -822,13 +826,15 @@ if ( document.querySelectorAll ) (function(){
|
||||||
return makeArray( context.querySelectorAll(query), extra );
|
return makeArray( context.querySelectorAll(query), extra );
|
||||||
} catch(e){}
|
} catch(e){}
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldSizzle(query, context, extra, seed);
|
return oldSizzle(query, context, extra, seed);
|
||||||
};
|
};
|
||||||
|
|
||||||
for ( var prop in oldSizzle ) {
|
for ( var prop in oldSizzle ) {
|
||||||
Sizzle[ prop ] = oldSizzle[ prop ];
|
Sizzle[ prop ] = oldSizzle[ prop ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div = null; // release memory in IE
|
||||||
})();
|
})();
|
||||||
|
|
||||||
if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){
|
if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){
|
||||||
|
@ -851,6 +857,8 @@ if ( document.getElementsByClassName && document.documentElement.getElementsByCl
|
||||||
return context.getElementsByClassName(match[1]);
|
return context.getElementsByClassName(match[1]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
div = null; // release memory in IE
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
||||||
|
@ -969,7 +977,7 @@ jQuery.expr = Sizzle.selectors;
|
||||||
jQuery.expr[":"] = jQuery.expr.filters;
|
jQuery.expr[":"] = jQuery.expr.filters;
|
||||||
|
|
||||||
Sizzle.selectors.filters.hidden = function(elem){
|
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){
|
Sizzle.selectors.filters.visible = function(elem){
|
||||||
|
|
Loading…
Reference in a new issue