title | short-title | slug | page-type | browser-compat |
---|---|---|---|---|
TrustedTypePolicyFactory: getPropertyType() method |
getPropertyType() |
Web/API/TrustedTypePolicyFactory/getPropertyType |
web-api-instance-method |
api.TrustedTypePolicyFactory.getPropertyType |
{{DefaultAPISidebar("Trusted Types API")}}
The getPropertyType()
method of the {{domxref("TrustedTypePolicyFactory")}} interface allows web developers to check if a Trusted Type is required for an element's property.
getPropertyType(tagName, property)
getPropertyType(tagName, property, elementNS)
tagName
- : A string containing the name of an HTML tag.
property
- : A string containing a property, for example
"innerHTML"
.
- : A string containing a property, for example
elementNS
{{optional_inline}}- : A string containing a namespace, if empty defaults to the HTML namespace.
A string with one of:
"TrustedHTML"
"TrustedScript"
"TrustedScriptURL"
Or, null.
In this example, passing the {{htmlelement("div")}} element and innerHTML
property to getPropertyType
returns "TrustedHTML".
console.log(trustedTypes.getPropertyType("div", "innerHTML")); // "TrustedHTML"
{{Specifications}}
{{Compat}}