TrustedTypePolicyFactory: getAttributeType() メソッド
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
メモ: この機能はウェブワーカー内で利用可能です。
getAttributeType()
は TrustedTypePolicyFactory
インターフェイスのメソッドで、ウェブ開発者が要素に対して信頼型が要求されるか、場合に必要な場合にどの信頼型を使用するかを調べることができます。
構文
js
getAttributeType(tagName, attribute)
getAttributeType(tagName, attribute, elementNS)
getAttributeType(tagName, attribute, elementNS, attrNS)
引数
tagName
-
HTML タグの名前の入った文字列です。
attribute
-
属性の入った文字列です。
elementNS
省略可-
名前空間が入った文字列。空の場合、既定で HTML 名前空間が使用されます。
attrNS
省略可-
名前空間が入った文字列。空の場合、既定で null となる。
返値
以下のいずれかの文字列。
"TrustedHTML"
"TrustedScript"
"TrustedScriptURL"
または null です。
例
この例では、 <script>
要素と src
属性を getAttributeType()
に渡すと、"TrustedScriptURL" が返されます。
js
console.log(trustedTypes.getAttributeType("script", "src")); // "TrustedScriptURL"
仕様書
Specification |
---|
Trusted Types> # dom-trustedtypepolicyfactory-getattributetype> |
ブラウザーの互換性
Loading…