MCPcopy Create free account
hub / github.com/dtmilano/AndroidViewClient / buildFragment

Function buildFragment

docs/_static/jquery-3.6.0.js:5006–5093  ·  view source on GitHub ↗
( elems, context, scripts, selection, ignored )

Source from the content-addressed store, hash-verified

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

Callers 2

domManipFunction · 0.85
jquery-3.6.0.jsFile · 0.85

Calls 4

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

Tested by

no test coverage detected