Skip to content

Commit fae809b

Browse files
committed
Rename cspTrustedTypesPolicy to cspTrustedTypesPolicyPromise.
1 parent 201a903 commit fae809b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ interface CSPTrustedHTMLToStringable {
1212
interface CSPTrustedTypesPolicy {
1313
createHTML: (s: string, response: Response) => CSPTrustedHTMLToStringable
1414
}
15-
let cspTrustedTypesPolicy: Promise<CSPTrustedTypesPolicy> | null = null
15+
let cspTrustedTypesPolicyPromise: Promise<CSPTrustedTypesPolicy> | null = null
1616
export function setCSPTrustedTypesPolicy(policy: CSPTrustedTypesPolicy | Promise<CSPTrustedTypesPolicy>): void {
17-
cspTrustedTypesPolicy = Promise.resolve(policy)
17+
cspTrustedTypesPolicyPromise = Promise.resolve(policy)
1818
}
1919

2020
export default class IncludeFragmentElement extends HTMLElement {
@@ -210,8 +210,9 @@ export default class IncludeFragmentElement extends HTMLElement {
210210

211211
const responseText: string = await response.text()
212212
let data: string | CSPTrustedHTMLToStringable = responseText
213-
if (cspTrustedTypesPolicy) {
214-
data = await cspTrustedTypesPolicy.then(policy => policy.createHTML(responseText, response))
213+
if (cspTrustedTypesPolicyPromise) {
214+
const cspTrustedTypesPolicy = await cspTrustedTypesPolicyPromise
215+
data = cspTrustedTypesPolicy.createHTML(responseText, response)
215216
}
216217

217218
// Dispatch `load` and `loadend` async to allow

0 commit comments

Comments
 (0)