},
buildFragment: function( elems, context, scripts, selection ) {
- var elem, i, j, tmp, tag, wrap, tbody,
- ret = [],
+ var elem, j, tmp, tag, wrap, tbody,
+ nodes = [],
+ i = 0,
+ l = elems.length,
fragment = context.createDocumentFragment(),
safe = context === document && safeFragment;
context = document;
}
- for ( i = 0; (elem = elems[i]) != null; i++ ) {
+ for ( ; i < l; i++ ) {
+ elem = elems[ i ];
if ( elem || elem === 0 ) {
// Add nodes directly
if ( jQuery.type( elem ) === "object" ) {
- jQuery.merge( ret, elem.nodeType ? [ elem ] : elem );
+ jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
// Convert non-html into a text node
} else if ( !rhtml.test( elem ) ) {
- ret.push( context.createTextNode( elem ) );
+ nodes.push( context.createTextNode( elem ) );
// Convert html into DOM nodes
} else {
// Manually add leading whitespace removed by IE
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
- ret.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
+ nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
}
// Remove IE's autoinserted <tbody> from table fragments
}
}
- jQuery.merge( ret, tmp.childNodes );
+ jQuery.merge( nodes, tmp.childNodes );
// Fix #12392 for WebKit and IE > 9
tmp.textContent = "";
// Reset defaultChecked for any radios and checkboxes
// about to be appended to the DOM in IE 6/7 (#8060)
if ( !jQuery.support.appendChecked ) {
- jQuery.grep( getAll( ret, "input" ), fixDefaultChecked );
+ jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
}
- for ( i = 0; (elem = ret[i]) != null; i++ ) {
+ i = 0;
+ while ( (elem = nodes[ i++ ]) ) {
safe = jQuery.contains( elem.ownerDocument, elem );
// Append to fragment
// Capture executables
if ( scripts ) {
- for ( j = 0; (elem = tmp[j]) != null; j++ ) {
+ j = 0;
+ while ( (elem = tmp[ j++ ]) ) {
if ( rscriptType.test( elem.type || "" ) ) {
scripts.push( elem );
}
var testAppend = function( valueObj ) {
- expect( 59 );
+ expect( 60 );
testAppendForObject( valueObj, false );
testAppendForObject( valueObj, true );
t( "Append Select", "#appendSelect1, #appendSelect2", [ "appendSelect1", "appendSelect2" ] );
equal( "Two nodes", jQuery("<div />").append( "Two", " nodes" ).text(), "Appending two text nodes (#4011)" );
+ equal( jQuery("<div />").append( "1", "", 3 ).text(), "13", "If median is false-like value, subsequent arguments should not be ignored" );
// using contents will get comments regular, text, and comment nodes
j = jQuery("#nonnodes").contents();