Skip to content

Commit 4aa0075

Browse files
authored
Update README
1 parent 672e836 commit 4aa0075

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Deferring the display of markup is typically done in the following usage pattern
105105
You can call `setCSPTrustedTypesPolicy(policy: TrustedTypePolicy | Promise<TrustedTypePolicy> | null)` from JavaScript to set a [CSP trusted types policy](https://web.dev/trusted-types/), which can perform (synchronous) filtering or rejection of the `fetch` response before it is inserted into the page:
106106

107107
```ts
108-
import { setCSPTrustedTypesPolicy } from "include-fragment-element";
108+
import IncludeFragmentElement from "include-fragment-element";
109109
import DOMPurify from "dompurify"; // Using https://github.com/cure53/DOMPurify
110110

111111
// This policy removes all HTML markup except links.
@@ -118,13 +118,13 @@ const policy = trustedTypes.createPolicy("links-only", {
118118
});
119119
},
120120
});
121-
setCSPTrustedTypesPolicy(policy);
121+
IncludeFragmentElement.setCSPTrustedTypesPolicy(policy);
122122
```
123123

124124
The policy has access to the `fetch` response object. Due to platform constraints, only synchronous information from the response (in addition to the HTML text body) can be used in the policy:
125125

126126
```ts
127-
import { setCSPTrustedTypesPolicy } from "include-fragment-element";
127+
import IncludeFragmentElement from "include-fragment-element";
128128

129129
const policy = trustedTypes.createPolicy("require-server-header", {
130130
createHTML: (htmlText: string, response: Response) => {
@@ -135,7 +135,7 @@ const policy = trustedTypes.createPolicy("require-server-header", {
135135
return htmlText;
136136
},
137137
});
138-
setCSPTrustedTypesPolicy(policy);
138+
IncludeFragmentElement.setCSPTrustedTypesPolicy(policy);
139139
```
140140

141141
Note that:

0 commit comments

Comments
 (0)