@@ -1070,26 +1081,16 @@ Given an {{HTMLScriptElement}} (|script|), this algorithm performs the following
## Get Trusted Types-compliant attribute value ## {#validate-attribute-mutation}
To get Trusted Types-compliant attribute value on {{Attr}} |attribute| with {{Element}} |element| and {{TrustedType}} or a string |newValue|, perform the following steps:
-1. Let |expectedType| be null.
-1. Let |sink| be null.
-1. Find the row in the following table, where |element| is in the first column, and |attribute|'s namespace and local name match the values in the second and third column, respectively.
- If a matching row is found, set |expectedType| and |sink| to the value of the fourth, and fifth column in that row, respectively.
-
-
-
- Element | Attribute namespace | Attribute local name | TrustedType | Sink
- |
- {{HTMLIFrameElement}} | null | "srcdoc" | {{TrustedHTML}} | "HTMLIFrameElement srcdoc"
- |
{{HTMLScriptElement}} | null | "src" | {{TrustedScriptURL}} | "HTMLScriptElement src"
- |
{{SVGScriptElement}} | null | "href" | {{TrustedScriptURL}} | "SVGScriptElement href"
- |
{{SVGScriptElement}} | XLink namespace | "href" | {{TrustedScriptURL}} | "SVGScriptElement href"
- |
-
-
-1. If |expectedType| is null, then:
+1. Set |attributeData| to the result of [$Get Trusted Type data for attribute$] algorithm, with the following arguments:
+ * |element|
+ * |attribute|'s
local name as |attribute|
+ * |attribute|'s
namespace as |attributeNs|
+1. If |attributeData| is null, then:
1. If |newValue| is a string, return |newValue|.
1.
Assert: |newValue| is {{TrustedHTML}} or {{TrustedScript}} or {{TrustedScriptURL}}.
1. Return |value|'s associated data.
+1. Let |expectedType| be the value of the third member of |attributeData|.
+1. Let |sink| be the value of the fourth member of |attributeData|.
1. Return the result of executing [$Get Trusted Type compliant string$] with the following arguments:
* |expectedType|
* |newValue| as |input|
@@ -1099,7 +1100,28 @@ To
get Trusted Types-compliant attribute value on
If the algorithm threw an error, rethrow the error.
-Issue: This algorithm should account for event handler attributes. See https://github.com/w3c/trusted-types/issues/474
+## Get Trusted Type data for attribute ## {#get-trusted-type-data-for-attribute}
+To
Get Trusted Type data for attribute given |element|, |attribute|, |attributeNs|, perform the following steps:
+
+1. Let |data| be null.
+1. If |attributeNs| is null, and |attribute| is the name of an [=event handler content attribute=], then:
+ 1. Return ({{Element}}, null, |attribute|, {{TrustedScript}}, "Element " + |attribute|).
+1. Find the row in the following table, where |element| is in the first column, |attributeNs| is in the second column,
+ and |attribute| is in the third column.
+ If a matching row is found, set |data| to that row.
+
+
+
+ Element | Attribute namespace | Attribute local name | TrustedType | Sink
+ |
+ {{HTMLIFrameElement}} | null | "srcdoc" | {{TrustedHTML}} | "HTMLIFrameElement srcdoc"
+ |
{{HTMLScriptElement}} | null | "src" | {{TrustedScriptURL}} | "HTMLScriptElement src"
+ |
{{SVGScriptElement}} | null | "href" | {{TrustedScriptURL}} | "SVGScriptElement href"
+ |
{{SVGScriptElement}} | XLink namespace | "href" | {{TrustedScriptURL}} | "SVGScriptElement href"
+ |
+
+
+1. Return |data|.
# Integrations # {#integrations}