diff options
author | Oleg <markelog@gmail.com> | 2013-01-09 13:23:34 +0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2013-01-09 09:52:01 -0500 |
commit | 8e6c1ba92faf830d40cafe7a4deb4ad5ab9045fe (patch) | |
tree | e6ed3b2aa90a10487e333a20c3447c8f697bed34 /src/manipulation.js | |
parent | 2f6b3f818fc51ee6ae44be69dc6b15b3d7a2dad4 (diff) | |
download | jquery-8e6c1ba92faf830d40cafe7a4deb4ad5ab9045fe.tar.gz jquery-8e6c1ba92faf830d40cafe7a4deb4ad5ab9045fe.zip |
Ref gh-1117: Don't stop on a falsy value in buildFragment. Close gh-1124.
Diffstat (limited to 'src/manipulation.js')
-rw-r--r-- | src/manipulation.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/manipulation.js b/src/manipulation.js index c85caa060..5b5d8aec4 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -424,10 +424,14 @@ jQuery.extend({ buildFragment: function( elems, context, scripts, selection ) { var elem, tmp, tag, wrap, contains, j, i = 0, + l = elems.length, fragment = context.createDocumentFragment(), nodes = []; - while ( ( elem = elems[ i++ ] ) || elem === 0 ) { + for ( ; i < l; i++ ) { + elem = elems[ i ]; + + if ( elem || elem === 0 ) { // Add nodes directly if ( jQuery.type( elem ) === "object" ) { @@ -461,6 +465,7 @@ jQuery.extend({ // Support: Webkit, IE tmp.textContent = ""; } + } } // Remove wrapper from fragment @@ -468,7 +473,6 @@ jQuery.extend({ i = 0; while ( (elem = nodes[ i++ ]) ) { - contains = jQuery.contains( elem.ownerDocument, elem ); // #4087 - If origin and destination elements are the same, and this is // that element, do not do anything @@ -476,6 +480,8 @@ jQuery.extend({ continue; } + contains = jQuery.contains( elem.ownerDocument, elem ); + // Append to fragment tmp = getAll( fragment.appendChild( elem ), "script" ); @@ -486,7 +492,6 @@ jQuery.extend({ // Capture executables if ( scripts ) { - j = 0; while ( (elem = tmp[ j++ ]) ) { if ( rscriptType.test( elem.type || "" ) ) { |