MCPcopy
hub / github.com/angular-ui/ui-router / jqLiteBuildFragment

Function jqLiteBuildFragment

test/angular/1.4/angular.js:2763–2798  ·  view source on GitHub ↗
(html, context)

Source from the content-addressed store, hash-verified

2761}
2762
2763function jqLiteBuildFragment(html, context) {
2764 var tmp, tag, wrap,
2765 fragment = context.createDocumentFragment(),
2766 nodes = [], i;
2767
2768 if (jqLiteIsTextNode(html)) {
2769 // Convert non-html into a text node
2770 nodes.push(context.createTextNode(html));
2771 } else {
2772 // Convert html into DOM nodes
2773 tmp = tmp || fragment.appendChild(context.createElement("div"));
2774 tag = (TAG_NAME_REGEXP.exec(html) || ["", ""])[1].toLowerCase();
2775 wrap = wrapMap[tag] || wrapMap._default;
2776 tmp.innerHTML = wrap[1] + html.replace(XHTML_TAG_REGEXP, "<$1></$2>") + wrap[2];
2777
2778 // Descend through wrappers to the right content
2779 i = wrap[0];
2780 while (i--) {
2781 tmp = tmp.lastChild;
2782 }
2783
2784 nodes = concat(nodes, tmp.childNodes);
2785
2786 tmp = fragment.firstChild;
2787 tmp.textContent = "";
2788 }
2789
2790 // Remove wrapper from fragment
2791 fragment.textContent = "";
2792 fragment.innerHTML = ""; // Clear inner HTML
2793 forEach(nodes, function(node) {
2794 fragment.appendChild(node);
2795 });
2796
2797 return fragment;
2798}
2799
2800function jqLiteParseHTML(html, context) {
2801 context = context || document;

Callers 2

jqLiteParseHTMLFunction · 0.70
angular.jsFile · 0.70

Calls 3

jqLiteIsTextNodeFunction · 0.70
concatFunction · 0.70
forEachFunction · 0.70

Tested by

no test coverage detected