X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fselector.js;h=8af3a0dba4274268182414fdb0cb8ad45c17aa0b;hb=626961c4a54cccaae0ecef81f2058cd0888611cc;hp=9fffeabd779ece022a64943d58aaa4a1e30f5bc0;hpb=d6e541426d10b335fa3b6b481ae591ede977c480;p=jquery.git diff --git a/src/selector.js b/src/selector.js index 9fffeab..8af3a0d 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; } @@ -494,7 +495,7 @@ var Expr = Sizzle.selectors = { CHILD: function(elem, match){ var type = match[1], parent = elem.parentNode; - var doneName = "child" + parent.childNodes.length; + var doneName = match[0]; if ( parent && (!parent[ doneName ] || !elem.nodeIndex) ) { var count = 1; @@ -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 && elem.nodeType === 9 && elem.nodeName !== "HTML" || - isXML( elem.ownerDocument ); + 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;