8 ], function( jQuery, rtagName, rscriptType, wrapMap, getAll, setGlobalEval ) {
10 var rhtml = /<|&#?\w+;/;
12 function buildFragment( elems, context, scripts, selection, ignored ) {
13 var elem, tmp, tag, wrap, contains, j,
14 fragment = context.createDocumentFragment(),
19 for ( ; i < l; i++ ) {
22 if ( elem || elem === 0 ) {
25 if ( jQuery.type( elem ) === "object" ) {
27 // Support: Android<4.1, PhantomJS<2
28 // push.apply(_, arraylike) throws on ancient WebKit
29 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
31 // Convert non-html into a text node
32 } else if ( !rhtml.test( elem ) ) {
33 nodes.push( context.createTextNode( elem ) );
35 // Convert html into DOM nodes
37 tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
39 // Deserialize a standard representation
40 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
41 wrap = wrapMap[ tag ] || wrapMap._default;
42 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
44 // Descend through wrappers to the right content
50 // Support: Android<4.1, PhantomJS<2
51 // push.apply(_, arraylike) throws on ancient WebKit
52 jQuery.merge( nodes, tmp.childNodes );
54 // Remember the top-level container
55 tmp = fragment.firstChild;
57 // Ensure the created nodes are orphaned (#12392)
63 // Remove wrapper from fragment
64 fragment.textContent = "";
67 while ( ( elem = nodes[ i++ ] ) ) {
69 // Skip elements already in the context collection (trac-4087)
70 if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
77 contains = jQuery.contains( elem.ownerDocument, elem );
80 tmp = getAll( fragment.appendChild( elem ), "script" );
82 // Preserve script evaluation history
87 // Capture executables
90 while ( ( elem = tmp[ j++ ] ) ) {
91 if ( rscriptType.test( elem.type || "" ) ) {
101 return buildFragment;