File tree Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change 1
- import { CSPTrustedHTMLToStringable , CSPTrustedTypesPolicy } from './trusted-types'
2
-
3
1
const privateData = new WeakMap ( )
4
2
5
3
function isWildcard ( accept : string | null ) {
6
4
return accept && ! ! accept . split ( ',' ) . find ( x => x . match ( / ^ \s * \* \/ \* / ) )
7
5
}
8
6
7
+ // We don't want to add `@types/trusted-types` as a dependency, so we use this stand-in.
8
+
9
+ interface CSPTrustedHTMLToStringable {
10
+ toString : ( ) => string
11
+ }
12
+ interface CSPTrustedTypesPolicy {
13
+ createHTML : ( s : string , response : Response ) => CSPTrustedHTMLToStringable
14
+ }
9
15
let cspTrustedTypesPolicy : Promise < CSPTrustedTypesPolicy > | null = null
10
16
export function setCSPTrusedTypesPolicy ( policy : CSPTrustedTypesPolicy | Promise < CSPTrustedTypesPolicy > ) : void {
11
17
cspTrustedTypesPolicy = Promise . resolve ( policy )
@@ -202,7 +208,7 @@ export default class IncludeFragmentElement extends HTMLElement {
202
208
throw new Error ( `Failed to load resource: expected ${ this . accept || 'text/html' } but was ${ ct } ` )
203
209
}
204
210
205
- let responseText : string = await response . text ( )
211
+ const responseText : string = await response . text ( )
206
212
let data : string | CSPTrustedHTMLToStringable = responseText
207
213
if ( cspTrustedTypesPolicy ) {
208
214
data = await cspTrustedTypesPolicy . then ( policy => policy . createHTML ( responseText , response ) )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments