MCPcopy
hub / github.com/layui/layui / buildFragment

Function buildFragment

src/modules/jquery.js:4795–4884  ·  view source on GitHub ↗
(elems, context, scripts, selection, ignored)

Source from the content-addressed store, hash-verified

4793 var rhtml = /<|&#?\w+;/;
4794
4795 function buildFragment(elems, context, scripts, selection, ignored) {
4796 var elem,
4797 tmp,
4798 tag,
4799 wrap,
4800 attached,
4801 j,
4802 fragment = context.createDocumentFragment(),
4803 nodes = [],
4804 i = 0,
4805 l = elems.length;
4806
4807 for (; i < l; i++) {
4808 elem = elems[i];
4809
4810 if (elem || elem === 0) {
4811 // Add nodes directly
4812 if (toType(elem) === 'object') {
4813 // Support: Android <=4.0 only, PhantomJS 1 only
4814 // push.apply(_, arraylike) throws on ancient WebKit
4815 jQuery.merge(nodes, elem.nodeType ? [elem] : elem);
4816
4817 // Convert non-html into a text node
4818 } else if (!rhtml.test(elem)) {
4819 nodes.push(context.createTextNode(elem));
4820
4821 // Convert html into DOM nodes
4822 } else {
4823 tmp = tmp || fragment.appendChild(context.createElement('div'));
4824
4825 // Deserialize a standard representation
4826 tag = (rtagName.exec(elem) || ['', ''])[1].toLowerCase();
4827 wrap = wrapMap[tag] || wrapMap._default;
4828 tmp.innerHTML = wrap[1] + jQuery.htmlPrefilter(elem) + wrap[2];
4829
4830 // Descend through wrappers to the right content
4831 j = wrap[0];
4832 while (j--) {
4833 tmp = tmp.lastChild;
4834 }
4835
4836 // Support: Android <=4.0 only, PhantomJS 1 only
4837 // push.apply(_, arraylike) throws on ancient WebKit
4838 jQuery.merge(nodes, tmp.childNodes);
4839
4840 // Remember the top-level container
4841 tmp = fragment.firstChild;
4842
4843 // Ensure the created nodes are orphaned (trac-12392)
4844 tmp.textContent = '';
4845 }
4846 }
4847 }
4848
4849 // Remove wrapper from fragment
4850 fragment.textContent = '';
4851
4852 i = 0;

Callers 2

domManipFunction · 0.85
jquery.jsFile · 0.85

Calls 4

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

Tested by

no test coverage detected