From 782b4af76ec080aad93d5c4a15fbc805f3e5960e Mon Sep 17 00:00:00 2001 From: John Resig Date: Sat, 14 Feb 2009 22:18:02 +0000 Subject: [PATCH] The compareDocumentPosition check was extraneous - indexOf works in all the other browsers that we need to support. --- src/selector.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/selector.js b/src/selector.js index 6b3b2da0..dd050659 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