From: John Resig Date: Sat, 14 Feb 2009 22:18:02 +0000 (+0000) Subject: The compareDocumentPosition check was extraneous - indexOf works in all the other... X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=782b4af76ec080aad93d5c4a15fbc805f3e5960e;p=jquery.git The compareDocumentPosition check was extraneous - indexOf works in all the other browsers that we need to support. --- diff --git a/src/selector.js b/src/selector.js index 6b3b2da..dd05065 100644 --- a/src/selector.js +++ b/src/selector.js @@ -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