MCPcopy Create free account
hub / github.com/angular/components / _setInnerHtml

Function _setInnerHtml

src/cdk/private/inner-html.ts:18–26  ·  view source on GitHub ↗
(element: HTMLElement, html: SafeHtml, sanitizer: DomSanitizer)

Source from the content-addressed store, hash-verified

16
17/** Sanitizes and sets the `innerHTML` of an element. */
18export function _setInnerHtml(element: HTMLElement, html: SafeHtml, sanitizer: DomSanitizer): void {
19 const cleanHtml = sanitizer.sanitize(SecurityContext.HTML, html);
20
21 if (cleanHtml === null && (typeof ngDevMode === 'undefined' || ngDevMode)) {
22 throw new Error(`Could not sanitize HTML: ${html}`);
23 }
24
25 element.innerHTML = trustedHTMLFromString(cleanHtml || '') as unknown as string;
26}

Callers 1

announceMethod · 0.90

Calls 1

trustedHTMLFromStringFunction · 0.90

Tested by

no test coverage detected