diff options
author | John Resig <jeresig@gmail.com> | 2009-02-17 17:43:05 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2009-02-17 17:43:05 +0000 |
commit | 4b7e1c906f497784329622d82da08c8646cae7e6 (patch) | |
tree | b68d56d47b84639831e747654d3dd91c0fd365ab /src/selector.js | |
parent | 8d9aa015c18e85f1f0aee1159e7928183483a5fd (diff) | |
download | jquery-4b7e1c906f497784329622d82da08c8646cae7e6.tar.gz jquery-4b7e1c906f497784329622d82da08c8646cae7e6.zip |
Brought back the compareDocumentPosition code. While it is redundant in Firefox it's much faster than using indexOf.
Diffstat (limited to 'src/selector.js')
-rw-r--r-- | src/selector.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/selector.js b/src/selector.js index c97ba61ff..6538d9706 100644 --- a/src/selector.js +++ b/src/selector.js @@ -684,7 +684,15 @@ try { var sortOrder; -if ( Array.prototype.indexOf ) { +if ( document.documentElement.compareDocumentPosition ) { + sortOrder = function( a, b ) { + var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; + if ( ret === 0 ) { + hasDuplicate = true; + } + return ret; + }; +} else if ( Array.prototype.indexOf ) { var indexOf = Array.prototype.indexOf, allSort = document.getElementsByTagName("*"); @@ -695,7 +703,7 @@ if ( Array.prototype.indexOf ) { } return ret; }; -} else if ( document.documentElement.sourceIndex === 1 ) { +} else if ( "sourceIndex" in document.documentElement ) { sortOrder = function( a, b ) { var ret = a.sourceIndex - b.sourceIndex; if ( ret === 0 ) { |