Side navigation
Ticket #1747: unique.patch
File unique.patch, 3.6 KB (added by rworth, September 28, 2007 04:58AM UTC)
Property changes on: src\ajax.js
___________________________________________________________________
Name: svn:eol-style
+ native
Index: src/core.js
===================================================================
--- src/core.js (revision 3486)
+++ src/core.js (working copy)
@@ -1093,8 +1093,11 @@
try {
for ( var i = 0, length = array.length; i < length; i++ ) {
- var id = jQuery.data( array[ i ] );
+ var id = array[ i ];
+ if ("object" == typeof array[ i ])
+ id = jQuery.data( array[ i ] );
+
if ( !done[ id ] ) {
done[ id ] = true;
ret.push( array[ i ] );
Property changes on: src\core.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: src\event.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: src\fx.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: src\intro.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: src\offset.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: src\outro.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: src\selector.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: test\unit\ajax.js
___________________________________________________________________
Name: svn:eol-style
+ native
Index: test/unit/core.js
===================================================================
--- test/unit/core.js (revision 3486)
+++ test/unit/core.js (working copy)
@@ -1074,3 +1074,18 @@
// Disabled, randomly fails
//ok( $("#iframe").contents()[0].body, "Check existance of IFrame body" );
});
+
+test("$.unique(array)", function() {
+ expect(9);
+ isSet( $.unique([]), [], "Check .unique() with empty array" );
+ isSet( $.unique([1, 2, 3]), [1, 2, 3], "Check with array of ints, no duplicates." );
+ isSet( $.unique([1, 1, 2, 2, 3, 3]), [1, 2, 3], "Check with array of ints, duplicates." );
+ isSet( $.unique(['a', 'b', 'c']), ['a', 'b', 'c'], "Check with array of strings, no duplicates." );
+ isSet( $.unique(['a', 'a', 'b', 'b', 'c', 'c']), ['a', 'b', 'c'], "Check with array of strings, duplicates." );
+ var arr1 = [1, 2], arr2 = ['a', 'b'];
+ isSet( $.unique([arr1, arr2]), [arr1, arr2], "Check with array of arrays, no duplicates." );
+ isSet( $.unique([arr1, arr2, arr1, arr2]), [arr1, arr2], "Check with array of arrays, duplicates." );
+ var obj1 = {"":"obj1"}, obj2 = {"":"obj2"};
+ isSet( $.unique([obj1, obj2]), [obj1, obj2], "Check with array of objects, no duplicates." );
+ isSet( $.unique([obj1, obj2, obj1, obj2]), [obj1, obj2], "Check with array of objects, duplicates." );
+});
Property changes on: test\unit\core.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: test\unit\event.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: test\unit\fx.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: test\unit\selector.js
___________________________________________________________________
Name: svn:eol-style
+ native
Download in other formats:
Original Format
File unique.patch, 3.6 KB (added by rworth, September 28, 2007 04:58AM UTC)
Property changes on: src\ajax.js
___________________________________________________________________
Name: svn:eol-style
+ native
Index: src/core.js
===================================================================
--- src/core.js (revision 3486)
+++ src/core.js (working copy)
@@ -1093,8 +1093,11 @@
try {
for ( var i = 0, length = array.length; i < length; i++ ) {
- var id = jQuery.data( array[ i ] );
+ var id = array[ i ];
+ if ("object" == typeof array[ i ])
+ id = jQuery.data( array[ i ] );
+
if ( !done[ id ] ) {
done[ id ] = true;
ret.push( array[ i ] );
Property changes on: src\core.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: src\event.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: src\fx.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: src\intro.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: src\offset.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: src\outro.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: src\selector.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: test\unit\ajax.js
___________________________________________________________________
Name: svn:eol-style
+ native
Index: test/unit/core.js
===================================================================
--- test/unit/core.js (revision 3486)
+++ test/unit/core.js (working copy)
@@ -1074,3 +1074,18 @@
// Disabled, randomly fails
//ok( $("#iframe").contents()[0].body, "Check existance of IFrame body" );
});
+
+test("$.unique(array)", function() {
+ expect(9);
+ isSet( $.unique([]), [], "Check .unique() with empty array" );
+ isSet( $.unique([1, 2, 3]), [1, 2, 3], "Check with array of ints, no duplicates." );
+ isSet( $.unique([1, 1, 2, 2, 3, 3]), [1, 2, 3], "Check with array of ints, duplicates." );
+ isSet( $.unique(['a', 'b', 'c']), ['a', 'b', 'c'], "Check with array of strings, no duplicates." );
+ isSet( $.unique(['a', 'a', 'b', 'b', 'c', 'c']), ['a', 'b', 'c'], "Check with array of strings, duplicates." );
+ var arr1 = [1, 2], arr2 = ['a', 'b'];
+ isSet( $.unique([arr1, arr2]), [arr1, arr2], "Check with array of arrays, no duplicates." );
+ isSet( $.unique([arr1, arr2, arr1, arr2]), [arr1, arr2], "Check with array of arrays, duplicates." );
+ var obj1 = {"":"obj1"}, obj2 = {"":"obj2"};
+ isSet( $.unique([obj1, obj2]), [obj1, obj2], "Check with array of objects, no duplicates." );
+ isSet( $.unique([obj1, obj2, obj1, obj2]), [obj1, obj2], "Check with array of objects, duplicates." );
+});
Property changes on: test\unit\core.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: test\unit\event.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: test\unit\fx.js
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: test\unit\selector.js
___________________________________________________________________
Name: svn:eol-style
+ native