]> source.dussan.org Git - jquery.git/commitdiff
Closes #2510
authorAriel Flesler <aflesler@gmail.com>
Tue, 13 May 2008 02:20:08 +0000 (02:20 +0000)
committerAriel Flesler <aflesler@gmail.com>
Tue, 13 May 2008 02:20:08 +0000 (02:20 +0000)
src/core.js

index a0533b178222d28712e30d659152a81d0e4d4eff..8743f05c49e54dc50ce3be0e965a58d83e32e8a3 100644 (file)
@@ -1146,17 +1146,17 @@ jQuery.extend({
        merge: function( first, second ) {
                // We have to loop this way because IE & Opera overwrite the length
                // expando of getElementsByTagName
-               var i = 0;
+               var i = 0, elem, pos = first.length;
                // Also, we need to make sure that the correct elements are being returned
                // (IE returns comment nodes in a '*' query)
                if ( jQuery.browser.msie ) {
-                       for ( ; second[ i ]; i++ )
-                               if ( second[ i ].nodeType != 8 )
-                                       first.push( second[ i ] );
+                       while ( elem = second[ i++ ] )
+                               if ( elem.nodeType != 8 )
+                                       first[ pos++ ] = elem;
 
                } else
-                       for ( ; second[ i ]; i++ )
-                               first.push( second[ i ] );
+                       while ( elem = second[ i++ ] )
+                               first[ pos++ ] = elem;
 
                return first;
        },