Skip to content

Commit

Permalink
Selector: add jQuery.uniqueSort; deprecate jQuery.unique
Browse files Browse the repository at this point in the history
Fixes gh-2228
  • Loading branch information
timmywil committed May 4, 2015
1 parent c916aef commit d9d930f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/selector-sizzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ define([
jQuery.find = Sizzle;
jQuery.expr = Sizzle.selectors;
jQuery.expr[":"] = jQuery.expr.pseudos;
jQuery.unique = Sizzle.uniqueSort;
jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
jQuery.text = Sizzle.getText;
jQuery.isXMLDoc = Sizzle.isXML;
jQuery.contains = Sizzle.contains;
Expand Down
6 changes: 3 additions & 3 deletions src/traversing.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jQuery.fn.extend({
}
}

return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
},

// Determine the position of an element within
Expand All @@ -109,7 +109,7 @@ jQuery.fn.extend({

add: function( selector, context ) {
return this.pushStack(
jQuery.unique(
jQuery.uniqueSort(
jQuery.merge( this.get(), jQuery( selector, context ) )
)
);
Expand Down Expand Up @@ -183,7 +183,7 @@ jQuery.each({
if ( this.length > 1 ) {
// Remove duplicates
if ( !guaranteedUnique[ name ] ) {
ret = jQuery.unique( ret );
ret = jQuery.uniqueSort( ret );
}

// Reverse order for parents* and prev-derivatives
Expand Down
2 changes: 1 addition & 1 deletion src/traversing/findFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jQuery.fn.extend({
jQuery.find( selector, self[ i ], ret );
}

return this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
return this.pushStack( len > 1 ? jQuery.uniqueSort( ret ) : ret );
},
filter: function( selector ) {
return this.pushStack( winnow(this, selector || [], false) );
Expand Down
6 changes: 3 additions & 3 deletions test/unit/selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ test( "jQuery.contains", function() {
ok( !jQuery.contains(document, detached), "document container (negative)" );
});

test("jQuery.unique", function() {
test("jQuery.uniqueSort", function() {
expect( 14 );

function Arrayish( arr ) {
Expand Down Expand Up @@ -459,8 +459,8 @@ test("jQuery.unique", function() {

jQuery.each( tests, function( label, test ) {
var length = test.length || test.input.length;
deepEqual( jQuery.unique( test.input ).slice( 0, length ), test.expected, label + " (array)" );
deepEqual( jQuery.unique( new Arrayish(test.input) ).slice( 0, length ), test.expected, label + " (quasi-array)" );
deepEqual( jQuery.uniqueSort( test.input ).slice( 0, length ), test.expected, label + " (array)" );
deepEqual( jQuery.uniqueSort( new Arrayish(test.input) ).slice( 0, length ), test.expected, label + " (quasi-array)" );
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/unit/traversing.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ test("sort direction", function() {

jQuery.each( methodDirections, function( method, reversed ) {
var actual = elems[ method ]().get(),
forward = jQuery.unique( [].concat( actual ) );
forward = jQuery.uniqueSort( [].concat( actual ) );
deepEqual( actual, reversed ? forward.reverse() : forward, "Correct sort direction for " + method );
});
});
Expand Down

0 comments on commit d9d930f

Please sign in to comment.