MCPcopy
hub / github.com/geekape/geek-navigation / buildFragment

Function buildFragment

js/jquery.js:4766–4853  ·  view source on GitHub ↗
( elems, context, scripts, selection, ignored )

Source from the content-addressed store, hash-verified

4764var rhtml = /<|&#?\w+;/;
4765
4766function buildFragment( elems, context, scripts, selection, ignored ) {
4767 var elem, tmp, tag, wrap, contains, j,
4768 fragment = context.createDocumentFragment(),
4769 nodes = [],
4770 i = 0,
4771 l = elems.length;
4772
4773 for ( ; i < l; i++ ) {
4774 elem = elems[ i ];
4775
4776 if ( elem || elem === 0 ) {
4777
4778 // Add nodes directly
4779 if ( jQuery.type( elem ) === "object" ) {
4780
4781 // Support: Android <=4.0 only, PhantomJS 1 only
4782 // push.apply(_, arraylike) throws on ancient WebKit
4783 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
4784
4785 // Convert non-html into a text node
4786 } else if ( !rhtml.test( elem ) ) {
4787 nodes.push( context.createTextNode( elem ) );
4788
4789 // Convert html into DOM nodes
4790 } else {
4791 tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
4792
4793 // Deserialize a standard representation
4794 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
4795 wrap = wrapMap[ tag ] || wrapMap._default;
4796 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
4797
4798 // Descend through wrappers to the right content
4799 j = wrap[ 0 ];
4800 while ( j-- ) {
4801 tmp = tmp.lastChild;
4802 }
4803
4804 // Support: Android <=4.0 only, PhantomJS 1 only
4805 // push.apply(_, arraylike) throws on ancient WebKit
4806 jQuery.merge( nodes, tmp.childNodes );
4807
4808 // Remember the top-level container
4809 tmp = fragment.firstChild;
4810
4811 // Ensure the created nodes are orphaned (#12392)
4812 tmp.textContent = "";
4813 }
4814 }
4815 }
4816
4817 // Remove wrapper from fragment
4818 fragment.textContent = "";
4819
4820 i = 0;
4821 while ( ( elem = nodes[ i++ ] ) ) {
4822
4823 // Skip elements already in the context collection (trac-4087)

Callers 2

domManipFunction · 0.85
jquery.jsFile · 0.85

Calls 2

getAllFunction · 0.85
setGlobalEvalFunction · 0.85

Tested by

no test coverage detected