TrustedTypePolicyFactory Class

https://w3c.github.io/trusted-types/dist/spec/#trusted-type-policy-factory: the trusted type policy factory of a global object (Window.TrustedTypes, WorkerGlobalScope.TrustedTypes). A document without a window (e.g. a document parsed without a browsing context) is its own global object: see Document.TrustedTypes.

public sealed class TrustedTypePolicyFactory

Properties

NameDescription
DefaultPolicyhttps://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-defaultpolicy
EmptyHtmlhttps://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-emptyhtml
EmptyScripthttps://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-emptyscript

https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-defaultpolicy

public TrustedTypePolicy? DefaultPolicy { get; }

https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-emptyhtml

public TrustedHtml EmptyHtml { get; }

https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-emptyscript

public TrustedScript EmptyScript { get; }

Methods

NameDescription
CreatePolicy(string, TrustedTypePolicyOptions?)https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-createpolicy
GetAttributeType(string, string, string?, string?)https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-getattributetype: the name of the trusted type required by a content attribute ("TrustedHTML", "TrustedScript" or "TrustedScriptURL"), or null.
GetPropertyType(string, string, string?)https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-getpropertytype: the name of the trusted type required by an IDL attribute of an element ("TrustedHTML", "TrustedScript" or "TrustedScriptURL"), or null.
IsHtml(object?)https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-ishtml
IsScript(object?)https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-isscript
IsScriptUrl(object?)https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-isscripturl

CreatePolicy(string, TrustedTypePolicyOptions?)

TrustedTypePolicyFactory.cs

https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-createpolicy

public TrustedTypePolicy CreatePolicy(string policyName, TrustedTypePolicyOptions? policyOptions = null)

Parameters

policyName string
policyOptions TrustedTypePolicyOptions?

Returns

TrustedTypePolicy

Exceptions

TypeErrorException
The creation of the policy is blocked by Document.TrustedTypesDirectives, or a default policy already exists.

See also

GetAttributeType(string, string, string?, string?)

TrustedTypePolicyFactory.cs

https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-getattributetype: the name of the trusted type required by a content attribute ("TrustedHTML", "TrustedScript" or "TrustedScriptURL"), or null.

public string? GetAttributeType(string tagName, string attribute, string? elementNs = "", string? attrNs = "")

GetPropertyType(string, string, string?)

TrustedTypePolicyFactory.cs

https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-getpropertytype: the name of the trusted type required by an IDL attribute of an element ("TrustedHTML", "TrustedScript" or "TrustedScriptURL"), or null.

public string? GetPropertyType(string tagName, string property, string? elementNs = "")

https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-ishtml

public bool IsHtml(object? value)

https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-isscript

public bool IsScript(object? value)

IsScriptUrl(object?)

TrustedTypePolicyFactory.cs

https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-isscripturl

public bool IsScriptUrl(object? value)