setTrustedTypesPolicy
Sets the Trusted Types policy that HTML is parsed through.
A page that enforces require-trusted-types-for 'script' rejects a plain
string assigned to innerHTML. With a policy set, the runtime assigns the
TrustedHTML that policy.createHTML(html) returns. It is asked for two
kinds of HTML: the static markup the compiler emitted for a template, and
the HTML a server component sends, which the frames client parses. The app
creates the policy, so its name and its checks stay under the app's
Content Security Policy:
setTrustedTypesPolicy( trustedTypes.createPolicy("my-app", { createHTML: (html) => html }));Call it before the first render. undefined goes back to plain strings.
Import
import { setTrustedTypesPolicy } from "@solidjs/web";Type signature
function setTrustedTypesPolicy( policy: { createHTML(html: string): unknown } | undefined): void;Parameters
policy
- Type:
{ createHTML(html: string): unknown } | undefined