MCPcopy
hub / github.com/angular/angular / insertDomInDocument

Function insertDomInDocument

packages/platform-server/test/dom_utils.ts:122–134  ·  view source on GitHub ↗
(doc: Document, html: string)

Source from the content-addressed store, hash-verified

120}
121
122export function insertDomInDocument(doc: Document, html: string) {
123 // Get HTML contents of the `<app>`, create a DOM element and append it into the body.
124 const container = convertHtmlToDom(html, doc);
125
126 // If there was a client render mode marker present in HTML - apply it to the <body>
127 // element as well.
128 const hasClientModeMarker = new RegExp(` ${CLIENT_RENDER_MODE_FLAG}`, 'g').test(html);
129 if (hasClientModeMarker) {
130 doc.body.setAttribute(CLIENT_RENDER_MODE_FLAG, '');
131 }
132
133 Array.from(container.childNodes).forEach((node) => doc.body.appendChild(node));
134}
135
136/**
137 * This prepares the environment before hydration begins.

Callers 1

prepareEnvironmentFunction · 0.85

Calls 5

convertHtmlToDomFunction · 0.85
setAttributeMethod · 0.65
appendChildMethod · 0.65
testMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…