MCPcopy Create free account
hub / github.com/TruthHun/BookStack / buildFragment

Function buildFragment

static/wangEditor/js/lib/jquery-2.2.1.js:4304–4391  ·  view source on GitHub ↗
( elems, context, scripts, selection, ignored )

Source from the content-addressed store, hash-verified

4302var rhtml = /<|&#?\w+;/;
4303
4304function buildFragment( elems, context, scripts, selection, ignored ) {
4305 var elem, tmp, tag, wrap, contains, j,
4306 fragment = context.createDocumentFragment(),
4307 nodes = [],
4308 i = 0,
4309 l = elems.length;
4310
4311 for ( ; i < l; i++ ) {
4312 elem = elems[ i ];
4313
4314 if ( elem || elem === 0 ) {
4315
4316 // Add nodes directly
4317 if ( jQuery.type( elem ) === "object" ) {
4318
4319 // Support: Android<4.1, PhantomJS<2
4320 // push.apply(_, arraylike) throws on ancient WebKit
4321 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
4322
4323 // Convert non-html into a text node
4324 } else if ( !rhtml.test( elem ) ) {
4325 nodes.push( context.createTextNode( elem ) );
4326
4327 // Convert html into DOM nodes
4328 } else {
4329 tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
4330
4331 // Deserialize a standard representation
4332 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
4333 wrap = wrapMap[ tag ] || wrapMap._default;
4334 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
4335
4336 // Descend through wrappers to the right content
4337 j = wrap[ 0 ];
4338 while ( j-- ) {
4339 tmp = tmp.lastChild;
4340 }
4341
4342 // Support: Android<4.1, PhantomJS<2
4343 // push.apply(_, arraylike) throws on ancient WebKit
4344 jQuery.merge( nodes, tmp.childNodes );
4345
4346 // Remember the top-level container
4347 tmp = fragment.firstChild;
4348
4349 // Ensure the created nodes are orphaned (#12392)
4350 tmp.textContent = "";
4351 }
4352 }
4353 }
4354
4355 // Remove wrapper from fragment
4356 fragment.textContent = "";
4357
4358 i = 0;
4359 while ( ( elem = nodes[ i++ ] ) ) {
4360
4361 // Skip elements already in the context collection (trac-4087)

Callers 2

domManipFunction · 0.70
jquery-2.2.1.jsFile · 0.70

Calls 2

getAllFunction · 0.70
setGlobalEvalFunction · 0.70

Tested by

no test coverage detected