MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / jqLiteBuildFragment

Function jqLiteBuildFragment

web/static/bower_components/angular/angular.js:2716–2751  ·  view source on GitHub ↗
(html, context)

Source from the content-addressed store, hash-verified

2714}
2715
2716function jqLiteBuildFragment(html, context) {
2717 var tmp, tag, wrap,
2718 fragment = context.createDocumentFragment(),
2719 nodes = [], i;
2720
2721 if (jqLiteIsTextNode(html)) {
2722 // Convert non-html into a text node
2723 nodes.push(context.createTextNode(html));
2724 } else {
2725 // Convert html into DOM nodes
2726 tmp = tmp || fragment.appendChild(context.createElement("div"));
2727 tag = (TAG_NAME_REGEXP.exec(html) || ["", ""])[1].toLowerCase();
2728 wrap = wrapMap[tag] || wrapMap._default;
2729 tmp.innerHTML = wrap[1] + html.replace(XHTML_TAG_REGEXP, "<$1></$2>") + wrap[2];
2730
2731 // Descend through wrappers to the right content
2732 i = wrap[0];
2733 while (i--) {
2734 tmp = tmp.lastChild;
2735 }
2736
2737 nodes = concat(nodes, tmp.childNodes);
2738
2739 tmp = fragment.firstChild;
2740 tmp.textContent = "";
2741 }
2742
2743 // Remove wrapper from fragment
2744 fragment.textContent = "";
2745 fragment.innerHTML = ""; // Clear inner HTML
2746 forEach(nodes, function(node) {
2747 fragment.appendChild(node);
2748 });
2749
2750 return fragment;
2751}
2752
2753function jqLiteParseHTML(html, context) {
2754 context = context || document;

Callers 2

jqLiteParseHTMLFunction · 0.85
angular.jsFile · 0.85

Calls 3

jqLiteIsTextNodeFunction · 0.85
concatFunction · 0.85
forEachFunction · 0.85

Tested by

no test coverage detected