The compareDocumentPosition check was extraneous - indexOf works in all the other...
authorJohn Resig <jeresig@gmail.com>
Sat, 14 Feb 2009 22:18:02 +0000 (22:18 +0000)
committerJohn Resig <jeresig@gmail.com>
Sat, 14 Feb 2009 22:18:02 +0000 (22:18 +0000)
src/selector.js

index 6b3b2da..dd05065 100644 (file)
@@ -663,9 +663,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;
                }
@@ -679,17 +682,6 @@ if ( document.documentElement.compareDocumentPosition ) {
                }
                return ret;
        };
-} else if ( Array.prototype.indexOf ) {
-       var indexOf = Array.prototype.indexOf,
-               allSort = document.getElementsByTagName("*");
-
-       sortOrder = function( a, b ) {
-               var ret = indexOf.call( allSort, a ) - indexOf.call( allSort, b );
-               if ( ret === 0 ) {
-                       hasDuplicate = true;
-               }
-               return ret;
-       };
 }
 
 // Check to see if the browser returns elements by name when