]> source.dussan.org Git - jquery.git/commitdiff
jquery core: Closes #3641. jQuery.merge stopped looping once a 0 was found.
authorAriel Flesler <aflesler@gmail.com>
Thu, 25 Dec 2008 19:25:30 +0000 (19:25 +0000)
committerAriel Flesler <aflesler@gmail.com>
Thu, 25 Dec 2008 19:25:30 +0000 (19:25 +0000)
src/core.js
test/unit/core.js

index a38e91ac81443e1d51a6bb81fe5f3fbf9d7b2c62..b35abade334a6ad169a74b70698f3a1cf7fd7d2a 100644 (file)
@@ -1149,12 +1149,12 @@ jQuery.extend({
                // Also, we need to make sure that the correct elements are being returned
                // (IE returns comment nodes in a '*' query)
                if ( !jQuery.support.getAll ) {
-                       while ( (elem = second[ i++ ]) )
+                       while ( (elem = second[ i++ ]) != null )
                                if ( elem.nodeType != 8 )
                                        first[ pos++ ] = elem;
 
                } else
-                       while ( (elem = second[ i++ ]) )
+                       while ( (elem = second[ i++ ]) != null )
                                first[ pos++ ] = elem;
 
                return first;
index 1ae2dfa5f93421c81da88e57d9ae3819cc15037c..679d50425e4506426b49018c2706e9700cb79459 100644 (file)
@@ -1138,6 +1138,21 @@ test("is(String)", function() {
        ok( jQuery('#en').is('[lang="de"] , [lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
 });
 
+test("jQuery.merge()", function() {
+       var parse = jQuery.merge;
+       
+       same( parse([],[]), [], "Empty arrays" );
+       
+       same( parse([1],[2]), [1,2], "Basic" );
+       same( parse([1,2],[3,4]), [1,2,3,4], "Basic" );
+       
+       same( parse([1,2],[]), [1,2], "Second empty" );
+       same( parse([],[1,2]), [1,2], "First empty" );  
+       
+       // Fixed at [5998], #3641
+       same( parse([-2,-1], [0,1,2]), [-2,-1,0,1,2], "Second array including a zero (falsy)");
+});
+
 test("jQuery.extend(Object, Object)", function() {
        expect(20);