diff --git a/dom.bs b/dom.bs index 31e95f0c..23d49703 100644 --- a/dom.bs +++ b/dom.bs @@ -53,9 +53,11 @@ spec:html; type:element

This specification depends on the Infra Standard. [[!INFRA]]

Some of the terms used in this specification are defined in Encoding, -Selectors, Web IDL, XML, and Namespaces in XML. +Selectors, Trusted Types, Web IDL, XML, and +Namespaces in XML. [[!ENCODING]] [[!SELECTORS4]] +[[!TRUSTED-TYPES]] [[!WEBIDL]] [[!XML]] [[!XML-NAMES]] @@ -6213,8 +6215,8 @@ interface Element : Node { sequence<DOMString> getAttributeNames(); DOMString? getAttribute(DOMString qualifiedName); DOMString? getAttributeNS(DOMString? namespace, DOMString localName); - [CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value); - [CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, DOMString value); + [CEReactions] undefined setAttribute(DOMString qualifiedName, (TrustedType or DOMString) value); + [CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, (TrustedType or DOMString) value); [CEReactions] undefined removeAttribute(DOMString qualifiedName); [CEReactions] undefined removeAttributeNS(DOMString? namespace, DOMString localName); [CEReactions] boolean toggleAttribute(DOMString qualifiedName, optional boolean force); @@ -6589,6 +6591,14 @@ steps: value. +

To verify attribute value given a {{TrustedType}} or string value, an +attribute attribute, and an Element element: + +

    +
  1. Return the result of calling get Trusted Types-compliant attribute value + given attribute, with element, and value. [[!TRUSTED-TYPES]] +

+
@@ -6641,6 +6651,10 @@ string namespace (default null):

attribute attr and an element element:
    +
  1. Let verifiedValue be the result of + verifying an attribute value given attr's + value, attr, and element. +

  2. If attr's element is neither null nor element, throw an "{{InUseAttributeError!!exception}}" {{DOMException}}. @@ -6656,29 +6670,58 @@ string namespace (default null):

  3. Otherwise, append attr to element. +

  4. Set attr's value to verifiedValue. +

  5. Return oldAttr.

To set an attribute value given an -element element, a string localName, a string value, -an optional null or string prefix (default null), and an optional null or string -namespace (default null): +element element, a string localName, a string or {{TrustedType}} +value, an optional null or string prefix (default null), an optional null or +string namespace (default null), and an optional boolean verify (default +false):

  1. Let attribute be the result of getting an attribute given namespace, localName, and element. -
  2. If attribute is null, create an attribute whose namespace is - namespace, namespace prefix is prefix, - local name is localName, value is value, and - node document is element's node document, then - append this attribute to element, and then - return. +
  3. Let attributeExists be false if attribute is null; otherwise true. + +

  4. If attributeExists is false, then set attribute to an attribute + whose namespace is namespace, namespace prefix is + prefix, local name is localName, value is + value, and node document is element's + node document. + +

  5. Let verifiedValue be value. + +

  6. +

    If verify is true: + +

      +
    1. Set verifiedValue to the result of + verifying an attribute value given value, + attribute, and element. + +

    2. Set attributeExists to true if element + has an attribute attribute; otherwise false. +

    +
  7. -
  8. Change attribute to value. +

  9. If attributeExists is true, change + attribute to verifiedValue. + +

  10. +

    Otherwise: + +

      +
    1. Set attribute's value to verifiedValue. + +

    2. Append this attribute to element. +

@@ -6939,12 +6982,30 @@ method steps are: and null otherwise. -
  • If attribute is null, create an attribute whose - local name is qualifiedName, value is - value, and node document is this's node document, - then append this attribute to this, and then return. +

  • Let attributeExists be false if attribute is null; otherwise true. + +

  • If attributeExists is false, then set attribute to an attribute + whose local name is qualifiedName, value is + value, and node document is this's node document. + +

  • Let verifiedValue be the result of + verifying an attribute value given value, + attribute, and this. + +

  • Set attributeExists to true if this + has an attribute attribute; otherwise false. + +

  • If attributeExists is true, change + attribute to verifiedValue. + +

  • +

    Otherwise: + +

      +
    1. Set attribute's value to verifiedValue. -

    2. Change attribute to value. +

    3. Append this attribute to element. +

    The @@ -6956,7 +7017,7 @@ method steps are: passing namespace and qualifiedName to validate and extract.

  • Set an attribute value for this using localName, value, - and also prefix and namespace. + prefix, namespace and true.

    The @@ -7514,7 +7575,24 @@ string value, run these steps:

  • If attribute's element is null, then set attribute's value to value. -

  • Otherwise, change attribute to value. +

  • +

    Otherwise: + +

      +
    1. Let originalElement be attribute's element. + +

    2. Let verifiedValue be the result of + verifying an attribute value given value, + attribute, and this. + +

    3. If attribute's element is null, then set attribute's + value to verifiedValue, and return. + +

    4. If attribute's element is not originalElement, then + return. + +

    5. Change attribute to verifiedValue. +

    The {{Attr/value}} setter steps are to set an existing attribute value with this