( elems, context, scripts, selection, ignored )
| 4597 | } |
| 4598 | |
| 4599 | function buildFragment( elems, context, scripts, selection, ignored ) { |
| 4600 | var j, elem, contains, |
| 4601 | tmp, tag, tbody, wrap, |
| 4602 | l = elems.length, |
| 4603 | |
| 4604 | // Ensure a safe fragment |
| 4605 | safe = createSafeFragment( context ), |
| 4606 | |
| 4607 | nodes = [], |
| 4608 | i = 0; |
| 4609 | |
| 4610 | for ( ; i < l; i++ ) { |
| 4611 | elem = elems[ i ]; |
| 4612 | |
| 4613 | if ( elem || elem === 0 ) { |
| 4614 | |
| 4615 | // Add nodes directly |
| 4616 | if ( jQuery.type( elem ) === "object" ) { |
| 4617 | jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); |
| 4618 | |
| 4619 | // Convert non-html into a text node |
| 4620 | } else if ( !rhtml.test( elem ) ) { |
| 4621 | nodes.push( context.createTextNode( elem ) ); |
| 4622 | |
| 4623 | // Convert html into DOM nodes |
| 4624 | } else { |
| 4625 | tmp = tmp || safe.appendChild( context.createElement( "div" ) ); |
| 4626 | |
| 4627 | // Deserialize a standard representation |
| 4628 | tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); |
| 4629 | wrap = wrapMap[ tag ] || wrapMap._default; |
| 4630 | |
| 4631 | tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; |
| 4632 | |
| 4633 | // Descend through wrappers to the right content |
| 4634 | j = wrap[ 0 ]; |
| 4635 | while ( j-- ) { |
| 4636 | tmp = tmp.lastChild; |
| 4637 | } |
| 4638 | |
| 4639 | // Manually add leading whitespace removed by IE |
| 4640 | if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
| 4641 | nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[ 0 ] ) ); |
| 4642 | } |
| 4643 | |
| 4644 | // Remove IE's autoinserted <tbody> from table fragments |
| 4645 | if ( !support.tbody ) { |
| 4646 | |
| 4647 | // String was a <table>, *may* have spurious <tbody> |
| 4648 | elem = tag === "table" && !rtbody.test( elem ) ? |
| 4649 | tmp.firstChild : |
| 4650 | |
| 4651 | // String was a bare <thead> or <tfoot> |
| 4652 | wrap[ 1 ] === "<table>" && !rtbody.test( elem ) ? |
| 4653 | tmp : |
| 4654 | 0; |
| 4655 | |
| 4656 | j = elem && elem.childNodes.length; |
no test coverage detected