Skip to content

Commit d9d930f

Browse files
committed
Selector: add jQuery.uniqueSort; deprecate jQuery.unique
Fixes gh-2228
1 parent c916aef commit d9d930f

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

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
@@ -84,7 +84,7 @@ jQuery.fn.extend({
8484
}
8585
}
8686

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

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

110110
add: function( selector, context ) {
111111
return this.pushStack(
112-
jQuery.unique(
112+
jQuery.uniqueSort(
113113
jQuery.merge( this.get(), jQuery( selector, context ) )
114114
)
115115
);
@@ -183,7 +183,7 @@ jQuery.each({
183183
if ( this.length > 1 ) {
184184
// Remove duplicates
185185
if ( !guaranteedUnique[ name ] ) {
186-
ret = jQuery.unique( ret );
186+
ret = jQuery.uniqueSort( ret );
187187
}
188188

189189
// 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
@@ -385,7 +385,7 @@ test( "jQuery.contains", function() {
385385
ok( !jQuery.contains(document, detached), "document container (negative)" );
386386
});
387387

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

391391
function Arrayish( arr ) {
@@ -459,8 +459,8 @@ test("jQuery.unique", function() {
459459

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

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)