X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fselector.js;h=f1745e4732bf1b59c9f53c1ef6525c37c6cf9291;hb=20827707a94c8569bcc422f71bf5b37bc55695df;hp=bc898e143d534073c80b5837d18a626519296462;hpb=e16c7fe0f8e2998d2e3ca1bc8f0794c43b29526f;p=jquery.git diff --git a/src/selector.js b/src/selector.js index bc898e1..f1745e4 100644 --- a/src/selector.js +++ b/src/selector.js @@ -223,8 +223,6 @@ Sizzle.filter = function(expr, set, inplace, not){ } } - expr = expr.replace(/\s*,\s*/, ""); - // Improper expression if ( expr == old ) { if ( anyFound == null ) { @@ -333,8 +331,9 @@ var Expr = Sizzle.selectors = { } }, NAME: function(match, context, isXML){ - if ( typeof context.getElementsByName !== "undefined" && !isXML ) { - return context.getElementsByName(match[1]); + if ( typeof context.getElementsByName !== "undefined" ) { + var ret = context.getElementsByName(match[1]); + return ret.length === 0 ? null : ret; } }, TAG: function(match, context){ @@ -398,7 +397,7 @@ var Expr = Sizzle.selectors = { PSEUDO: function(match, curLoop, inplace, result, not){ if ( match[1] === "not" ) { // If we're dealing with a complex expression, or a simple one - if ( match[3].match(chunker).length > 1 ) { + if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) { match[3] = Sizzle(match[3], null, null, curLoop); } else { var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); @@ -663,15 +662,18 @@ try { var sortOrder; -if ( document.documentElement.compareDocumentPosition ) { +if ( Array.prototype.indexOf ) { + var indexOf = Array.prototype.indexOf, + allSort = document.getElementsByTagName("*"); + sortOrder = function( a, b ) { - var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; + var ret = indexOf.call( allSort, a ) - indexOf.call( allSort, b ); if ( ret === 0 ) { hasDuplicate = true; } return ret; }; -} else if ( document.documentElement.sourceIndex === 0 ) { +} else if ( document.documentElement.sourceIndex === 1 ) { sortOrder = function( a, b ) { var ret = a.sourceIndex - b.sourceIndex; if ( ret === 0 ) {