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

Function jqLiteBuildFragment

test/angular/1.3/angular.js:2465–2500  ·  view source on GitHub ↗
(html, context)

Source from the content-addressed store, hash-verified

2463}
2464
2465function jqLiteBuildFragment(html, context) {
2466 var tmp, tag, wrap,
2467 fragment = context.createDocumentFragment(),
2468 nodes = [], i;
2469
2470 if (jqLiteIsTextNode(html)) {
2471 // Convert non-html into a text node
2472 nodes.push(context.createTextNode(html));
2473 } else {
2474 // Convert html into DOM nodes
2475 tmp = tmp || fragment.appendChild(context.createElement("div"));
2476 tag = (TAG_NAME_REGEXP.exec(html) || ["", ""])[1].toLowerCase();
2477 wrap = wrapMap[tag] || wrapMap._default;
2478 tmp.innerHTML = wrap[1] + html.replace(XHTML_TAG_REGEXP, "<$1></$2>") + wrap[2];
2479
2480 // Descend through wrappers to the right content
2481 i = wrap[0];
2482 while (i--) {
2483 tmp = tmp.lastChild;
2484 }
2485
2486 nodes = concat(nodes, tmp.childNodes);
2487
2488 tmp = fragment.firstChild;
2489 tmp.textContent = "";
2490 }
2491
2492 // Remove wrapper from fragment
2493 fragment.textContent = "";
2494 fragment.innerHTML = ""; // Clear inner HTML
2495 forEach(nodes, function(node) {
2496 fragment.appendChild(node);
2497 });
2498
2499 return fragment;
2500}
2501
2502function jqLiteParseHTML(html, context) {
2503 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