Skip to content

Latest commit

 

History

History
53 lines (36 loc) · 1.25 KB

File metadata and controls

53 lines (36 loc) · 1.25 KB
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.

Syntax

getPropertyType(tagName, property)
getPropertyType(tagName, property, elementNS)

Parameters

  • tagName
    • : A string containing the name of an HTML tag.
  • property
    • : A string containing a property, for example "innerHTML".
  • elementNS {{optional_inline}}
    • : A string containing a namespace, if empty defaults to the HTML namespace.

Return value

A string with one of:

  • "TrustedHTML"
  • "TrustedScript"
  • "TrustedScriptURL"

Or, null.

Examples

In this example, passing the {{htmlelement("div")}} element and innerHTML property to getPropertyType returns "TrustedHTML".

console.log(trustedTypes.getPropertyType("div", "innerHTML")); // "TrustedHTML"

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}