Permalink
Browse files

Selector: Define jQuery.uniqueSort in selector-native too

Fixes gh-2466
Closes gh-2467
  • Loading branch information...
mlewand authored and gibson042 committed Jul 13, 2015
1 parent c44dd77 commit bf591fb597a056bf2fc9bc474010374695b18d1a
Showing with 24 additions and 22 deletions.
  1. +24 −22 src/selector-native.js
View
@@ -67,6 +67,28 @@ var hasDuplicate,
// Not directly comparable, sort on existence of method
return a.compareDocumentPosition ? -1 : 1;
},
uniqueSort = function( results ) {
var elem,
duplicates = [],
i = 0,
j = 0;
hasDuplicate = false;
results.sort( sortOrder );
if ( hasDuplicate ) {
while ( (elem = results[i++]) ) {
if ( elem === results[ i ] ) {
j = duplicates.push( i );
}
}
while ( j-- ) {
results.splice( duplicates[ j ], 1 );
}
}
return results;
};
jQuery.extend({
@@ -99,28 +121,8 @@ jQuery.extend({
return results;
},
unique: function( results ) {
var elem,
duplicates = [],
i = 0,
j = 0;
hasDuplicate = false;
results.sort( sortOrder );
if ( hasDuplicate ) {
while ( (elem = results[i++]) ) {
if ( elem === results[ i ] ) {
j = duplicates.push( i );
}
}
while ( j-- ) {
results.splice( duplicates[ j ], 1 );
}
}
return results;
},
uniqueSort: uniqueSort,
unique: uniqueSort,
text: function( elem ) {
var node,
ret = "",

0 comments on commit bf591fb

Please sign in to comment.