File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 2828 " src/**/*spec.ts" ,
2929 " src/cdk/schematics/**/*" ,
3030 " src/cdk/testing/private/**/*" ,
31+ " src/cdk/private/inner-html.ts" ,
3132 " src/material/schematics/**/*" ,
3233 " src/material/schematics/ng-generate/theme-color/**/*.bazel" ,
3334 " src/material/schematics/ng-generate/theme-color/index_bundled.d.ts" ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ ng_project(
1111 assets = [":visually-hidden-styles" ],
1212 deps = [
1313 "//:node_modules/@angular/core" ,
14+ "//:node_modules/@angular/platform-browser" ,
1415 ],
1516)
1617
Original file line number Diff line number Diff line change 1+ /**
2+ * @license
3+ * Copyright Google LLC All Rights Reserved.
4+ *
5+ * Use of this source code is governed by an MIT-style license that can be
6+ * found in the LICENSE file at https://angular.dev/license
7+ */
8+
9+ import { SecurityContext } from '@angular/core' ;
10+ import { DomSanitizer , SafeHtml } from '@angular/platform-browser' ;
11+ import { trustedHTMLFromString } from './trusted-types' ;
12+
13+ // !!!Note!!! this file isn't synced into g3, but is replaced with a version that uses
14+ // internal-specific APIs. The internal version may have to be updated if the signature of
15+ // the function changes.
16+
17+ /** Sanitizes and sets the `innerHTML` of an element. */
18+ export 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+ }
You can’t perform that action at this time.
0 commit comments