Skip to content

Commit 4ff5d3d

Browse files
committed
Allow clearing the policy using null.
1 parent 0b02f05 commit 4ff5d3d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ interface CSPTrustedTypesPolicy {
1313
createHTML: (s: string, response: Response) => CSPTrustedHTMLToStringable
1414
}
1515
let cspTrustedTypesPolicyPromise: Promise<CSPTrustedTypesPolicy> | null = null
16-
export function setCSPTrustedTypesPolicy(policy: CSPTrustedTypesPolicy | Promise<CSPTrustedTypesPolicy>): void {
17-
cspTrustedTypesPolicyPromise = Promise.resolve(policy)
16+
// Passing `null` clears the policy.
17+
export function setCSPTrustedTypesPolicy(policy: CSPTrustedTypesPolicy | Promise<CSPTrustedTypesPolicy> | null): void {
18+
cspTrustedTypesPolicyPromise = policy === null ? policy : Promise.resolve(policy)
1819
}
1920

2021
export default class IncludeFragmentElement extends HTMLElement {

0 commit comments

Comments
 (0)