X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fselector.js;h=ecec83b9fccc833a39135974e754ebf5ee2bec3b;hb=21dde30348fe9bcbd8db8c1b30e470a9e2f39c16;hp=5712f572b79f24d809d0660b4c7f693fe79c065f;hpb=7421f342840947a746aa6be944221e931e3556cc;p=jquery.git diff --git a/src/selector.js b/src/selector.js index 5712f57..ecec83b 100644 --- a/src/selector.js +++ b/src/selector.js @@ -333,8 +333,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){ @@ -663,9 +664,12 @@ 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; }