Skip to content

Commit 782b4af

Browse files
committed
The compareDocumentPosition check was extraneous - indexOf works in all the other browsers that we need to support.
1 parent 6f4b08c commit 782b4af

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/selector.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,12 @@ try {
663663

664664
var sortOrder;
665665

666-
if ( document.documentElement.compareDocumentPosition ) {
666+
if ( Array.prototype.indexOf ) {
667+
var indexOf = Array.prototype.indexOf,
668+
allSort = document.getElementsByTagName("*");
669+
667670
sortOrder = function( a, b ) {
668-
var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
671+
var ret = indexOf.call( allSort, a ) - indexOf.call( allSort, b );
669672
if ( ret === 0 ) {
670673
hasDuplicate = true;
671674
}
@@ -679,17 +682,6 @@ if ( document.documentElement.compareDocumentPosition ) {
679682
}
680683
return ret;
681684
};
682-
} else if ( Array.prototype.indexOf ) {
683-
var indexOf = Array.prototype.indexOf,
684-
allSort = document.getElementsByTagName("*");
685-
686-
sortOrder = function( a, b ) {
687-
var ret = indexOf.call( allSort, a ) - indexOf.call( allSort, b );
688-
if ( ret === 0 ) {
689-
hasDuplicate = true;
690-
}
691-
return ret;
692-
};
693685
}
694686

695687
// Check to see if the browser returns elements by name when

0 commit comments

Comments
 (0)