Permalink
Browse files

Selector: add jQuery.uniqueSort; deprecate jQuery.unique

Fixes gh-2228
  • Loading branch information...
timmywil committed May 4, 2015
1 parent 7a6931d commit e1090c3d2b2a988a5b41f1f1ed9f8d6dcae02200
Showing with 9 additions and 9 deletions.
  1. +1 −1 src/selector-sizzle.js
  2. +3 −3 src/traversing.js
  3. +1 −1 src/traversing/findFilter.js
  4. +3 −3 test/unit/selector.js
  5. +1 −1 test/unit/traversing.js
View
@@ -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;
View
@@ -85,7 +85,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 the set
@@ -111,7 +111,7 @@ jQuery.fn.extend({
add: function( selector, context ) {
return this.pushStack(
jQuery.unique(
jQuery.uniqueSort(
jQuery.merge( this.get(), jQuery( selector, context ) )
)
);
@@ -182,7 +182,7 @@ jQuery.each({
if ( this.length > 1 ) {
// Remove duplicates
if ( !guaranteedUnique[ name ] ) {
jQuery.unique( matched );
jQuery.uniqueSort( matched );
}
// Reverse order for parents* and prev-derivatives
@@ -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) );
View
@@ -386,7 +386,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 ) {
@@ -460,8 +460,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)" );
});
});
View
@@ -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 );
});
});

6 comments on commit e1090c3

@mgol

This comment has been minimized.

Show comment
Hide comment
@mgol

mgol May 5, 2015

Member

Shouldn't we have one test that asserts that jQuery.unique & jQuery.uniqueSort are identical?

Member

mgol replied May 5, 2015

Shouldn't we have one test that asserts that jQuery.unique & jQuery.uniqueSort are identical?

@timmywil

This comment has been minimized.

Show comment
Hide comment
@timmywil

timmywil May 5, 2015

Member

You think? I figure with an alias, if you test one, you test the other too.

Member

timmywil replied May 5, 2015

You think? I figure with an alias, if you test one, you test the other too.

@scottgonzalez

This comment has been minimized.

Show comment
Hide comment
@scottgonzalez

scottgonzalez May 5, 2015

Member

I believe @mzgol is saying that strictEqual( jQuery.unique, jQuery.uniqueSort, "jQuery.unique() is an alias to jQuery.uniqueSort()" ) should be added.

Member

scottgonzalez replied May 5, 2015

I believe @mzgol is saying that strictEqual( jQuery.unique, jQuery.uniqueSort, "jQuery.unique() is an alias to jQuery.uniqueSort()" ) should be added.

@timmywil

This comment has been minimized.

Show comment
Hide comment
@timmywil

timmywil May 5, 2015

Member

Fair enough. Will add.

Member

timmywil replied May 5, 2015

Fair enough. Will add.

@timmywil

This comment has been minimized.

Show comment
Hide comment
@timmywil
Member

timmywil replied May 5, 2015

@mgol

This comment has been minimized.

Show comment
Hide comment
@mgol

mgol May 5, 2015

Member

@timmywil Yup, I meant what @scottgonzalez wrote. Thanks!

Member

mgol replied May 5, 2015

@timmywil Yup, I meant what @scottgonzalez wrote. Thanks!

Please sign in to comment.