Skip to content

Commit e1090c3

Browse files
committed
Selector: add jQuery.uniqueSort; deprecate jQuery.unique
Fixes gh-2228
1 parent 7a6931d commit e1090c3

5 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/selector-sizzle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ define([
66
jQuery.find = Sizzle;
77
jQuery.expr = Sizzle.selectors;
88
jQuery.expr[":"] = jQuery.expr.pseudos;
9-
jQuery.unique = Sizzle.uniqueSort;
9+
jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
1010
jQuery.text = Sizzle.getText;
1111
jQuery.isXMLDoc = Sizzle.isXML;
1212
jQuery.contains = Sizzle.contains;

src/traversing.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jQuery.fn.extend({
8585
}
8686
}
8787

88-
return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
88+
return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
8989
},
9090

9191
// Determine the position of an element within the set
@@ -111,7 +111,7 @@ jQuery.fn.extend({
111111

112112
add: function( selector, context ) {
113113
return this.pushStack(
114-
jQuery.unique(
114+
jQuery.uniqueSort(
115115
jQuery.merge( this.get(), jQuery( selector, context ) )
116116
)
117117
);
@@ -182,7 +182,7 @@ jQuery.each({
182182
if ( this.length > 1 ) {
183183
// Remove duplicates
184184
if ( !guaranteedUnique[ name ] ) {
185-
jQuery.unique( matched );
185+
jQuery.uniqueSort( matched );
186186
}
187187

188188
// Reverse order for parents* and prev-derivatives

src/traversing/findFilter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jQuery.fn.extend({
7272
jQuery.find( selector, self[ i ], ret );
7373
}
7474

75-
return this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
75+
return this.pushStack( len > 1 ? jQuery.uniqueSort( ret ) : ret );
7676
},
7777
filter: function( selector ) {
7878
return this.pushStack( winnow(this, selector || [], false) );

test/unit/selector.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ test( "jQuery.contains", function() {
386386
ok( !jQuery.contains(document, detached), "document container (negative)" );
387387
});
388388

389-
test("jQuery.unique", function() {
389+
test("jQuery.uniqueSort", function() {
390390
expect( 14 );
391391

392392
function Arrayish( arr ) {
@@ -460,8 +460,8 @@ test("jQuery.unique", function() {
460460

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

test/unit/traversing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ test("sort direction", function() {
696696

697697
jQuery.each( methodDirections, function( method, reversed ) {
698698
var actual = elems[ method ]().get(),
699-
forward = jQuery.unique( [].concat( actual ) );
699+
forward = jQuery.uniqueSort( [].concat( actual ) );
700700
deepEqual( actual, reversed ? forward.reverse() : forward, "Correct sort direction for " + method );
701701
});
702702
});

0 commit comments

Comments
 (0)