X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fselector.js;h=6b68cb28bc1352a62b81a3e7597a3380e1696e63;hb=db10da345e84e86d66a613e33e97916a7facb94f;hp=682a92ebe1dc44afe36a56202ad08a7854466a42;hpb=8e8d7ade434de3d79cc6145f370866f297a07b54;p=jquery.git diff --git a/src/selector.js b/src/selector.js index 682a92e..6b68cb2 100644 --- a/src/selector.js +++ b/src/selector.js @@ -6,7 +6,7 @@ */ (function(){ -var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|[^[\]]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g, +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]+['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g, done = 0, toString = Object.prototype.toString; @@ -332,11 +332,12 @@ var Expr = Sizzle.selectors = { CLASS: function(match, curLoop, inplace, result, not){ match = " " + match[1].replace(/\\/g, "") + " "; - for ( var i = 0; curLoop[i] != null; i++ ) { - if ( curLoop[i] ) { - if ( not ^ (" " + curLoop[i].className + " ").indexOf(match) >= 0 ) { + var elem; + for ( var i = 0; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (" " + elem.className + " ").indexOf(match) >= 0 ) { if ( !inplace ) - result.push( curLoop[i] ); + result.push( elem ); } else if ( inplace ) { curLoop[i] = false; } @@ -700,7 +701,7 @@ try { // Check to see if an attribute returns normalized href attributes div.innerHTML = ""; - if ( div.firstChild.getAttribute("href") !== "#" ) { + if ( div.firstChild && div.firstChild.getAttribute("href") !== "#" ) { Expr.attrHandle.href = function(elem){ return elem.getAttribute("href", 2); }; @@ -809,8 +810,8 @@ var contains = document.compareDocumentPosition ? function(a, b){ }; var isXML = function(elem){ - return elem.documentElement && !elem.body || - elem.tagName && elem.ownerDocument && !elem.ownerDocument.body; + return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || + !!elem.ownerDocument && isXML( elem.ownerDocument ); }; var posProcess = function(selector, context){ @@ -831,7 +832,7 @@ var posProcess = function(selector, context){ } return Sizzle.filter( later, tmpSet ); -} +}; // EXPOSE jQuery.find = Sizzle;