MCPcopy Create free account
hub / github.com/OpenIntroStat/ims / buildFragment

Function buildFragment

libs/jquery-3.5.1/jquery-3.5.1.js:5002–5089  ·  view source on GitHub ↗
( elems, context, scripts, selection, ignored )

Source from the content-addressed store, hash-verified

5000var rhtml = /<|&#?\w+;/;
5001
5002function buildFragment( elems, context, scripts, selection, ignored ) {
5003 var elem, tmp, tag, wrap, attached, j,
5004 fragment = context.createDocumentFragment(),
5005 nodes = [],
5006 i = 0,
5007 l = elems.length;
5008
5009 for ( ; i < l; i++ ) {
5010 elem = elems[ i ];
5011
5012 if ( elem || elem === 0 ) {
5013
5014 // Add nodes directly
5015 if ( toType( elem ) === "object" ) {
5016
5017 // Support: Android <=4.0 only, PhantomJS 1 only
5018 // push.apply(_, arraylike) throws on ancient WebKit
5019 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
5020
5021 // Convert non-html into a text node
5022 } else if ( !rhtml.test( elem ) ) {
5023 nodes.push( context.createTextNode( elem ) );
5024
5025 // Convert html into DOM nodes
5026 } else {
5027 tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
5028
5029 // Deserialize a standard representation
5030 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
5031 wrap = wrapMap[ tag ] || wrapMap._default;
5032 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
5033
5034 // Descend through wrappers to the right content
5035 j = wrap[ 0 ];
5036 while ( j-- ) {
5037 tmp = tmp.lastChild;
5038 }
5039
5040 // Support: Android <=4.0 only, PhantomJS 1 only
5041 // push.apply(_, arraylike) throws on ancient WebKit
5042 jQuery.merge( nodes, tmp.childNodes );
5043
5044 // Remember the top-level container
5045 tmp = fragment.firstChild;
5046
5047 // Ensure the created nodes are orphaned (#12392)
5048 tmp.textContent = "";
5049 }
5050 }
5051 }
5052
5053 // Remove wrapper from fragment
5054 fragment.textContent = "";
5055
5056 i = 0;
5057 while ( ( elem = nodes[ i++ ] ) ) {
5058
5059 // Skip elements already in the context collection (trac-4087)

Callers 2

domManipFunction · 0.70
jquery-3.5.1.jsFile · 0.70

Calls 4

toTypeFunction · 0.85
isAttachedFunction · 0.85
getAllFunction · 0.70
setGlobalEvalFunction · 0.70

Tested by

no test coverage detected