Skip to content

Commit

Permalink
jquery core: Closes #3641. jQuery.merge stopped looping once a 0 was …
Browse files Browse the repository at this point in the history
…found.
  • Loading branch information
flesler committed Dec 25, 2008
1 parent 5459180 commit 4b25b14
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core.js
Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions test/unit/core.js
Expand Up @@ -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);

Expand Down

0 comments on commit 4b25b14

Please sign in to comment.