mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Change SvgIconInfo.svgSource to be a TrustedHTML and update all its users accordingly. Also introduce the svg template tag function for building TrustedHTML from constant SVG sources. PR Close #42800
17 lines
718 B
TypeScript
17 lines
718 B
TypeScript
import { htmlFromStringKnownToSatisfyTypeContract } from 'safevalues/unsafe/reviewed';
|
|
|
|
export function fromInnerHTML(el: Element): TrustedHTML {
|
|
// SECURITY: Existing innerHTML content is already trusted.
|
|
return htmlFromStringKnownToSatisfyTypeContract(el.innerHTML, '^');
|
|
}
|
|
|
|
export function fromOuterHTML(el: Element): TrustedHTML {
|
|
// SECURITY: Existing outerHTML content is already trusted.
|
|
return htmlFromStringKnownToSatisfyTypeContract(el.outerHTML, '^');
|
|
}
|
|
|
|
export function svg(constantSvg: TemplateStringsArray): TrustedHTML {
|
|
// SECURITY: Template literal argument with no interpolation is constant, and
|
|
// hence trusted.
|
|
return htmlFromStringKnownToSatisfyTypeContract(constantSvg[0], '^');
|
|
}
|