diff options
author | John Resig <jeresig@gmail.com> | 2009-02-25 15:19:08 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2009-02-25 15:19:08 +0000 |
commit | 1c5db3babaf32f6faa7e9e867990110c9713f64b (patch) | |
tree | 5173c70a5450d2758c138d444303bd3f5248508d | |
parent | 85e0945718dd8108577b7b4b5b3c86def3bfb17c (diff) | |
download | jquery-1c5db3babaf32f6faa7e9e867990110c9713f64b.tar.gz jquery-1c5db3babaf32f6faa7e9e867990110c9713f64b.zip |
Expose the sort/unique code from Sizzle as Sizzle.uniqueSort().
-rw-r--r-- | src/selector.js | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/selector.js b/src/selector.js index 2e6d8e1ab..48aeea551 100644 --- a/src/selector.js +++ b/src/selector.js @@ -124,22 +124,25 @@ var Sizzle = function(selector, context, results, seed) { if ( extra ) { Sizzle( extra, origContext, results, seed ); + Sizzle.uniqueSort( results ); + } - if ( sortOrder ) { - hasDuplicate = false; - results.sort(sortOrder); + return results; +}; - if ( hasDuplicate ) { - for ( var i = 1; i < results.length; i++ ) { - if ( results[i] === results[i-1] ) { - results.splice(i--, 1); - } +Sizzle.uniqueSort = function(results){ + if ( sortOrder ) { + hasDuplicate = false; + results.sort(sortOrder); + + if ( hasDuplicate ) { + for ( var i = 1; i < results.length; i++ ) { + if ( results[i] === results[i-1] ) { + results.splice(i--, 1); } } } } - - return results; }; Sizzle.matches = function(expr, set){ |