@@ -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,30 @@ 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:
+
+Issue: The [=event handler content attribute=] concept used below is ambiguous. This spec needs a better mechanism to identify event handler attributes. See [https://github.com/w3c/trusted-types/issues/520](https://github.com/w3c/trusted-types/issues/520).
+
+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}
@@ -1256,9 +1280,9 @@ abstract operation. User agents must use the following implementation:
### Validate the string in context ### {#html-validate-the-string-in-context}
-This specification defines the
validate the string in context algorithm in [[html#integration-with-idl]].
+This specification defines the validate the string in context algorithm in [[html#integration-with-idl]].
-When
validate the string in context is invoked, with |platformObject|, |value|, |stringContext|, and |identifier| run these steps:
+When validate the string in context is invoked, with |platformObject|, |value|, |stringContext|, and |identifier| run these steps:
1. If |platformObject|'s [=relevant global object=] has a [=Window/trusted type policy factory=]: