From 67c0b7c8c17b269e44b4cf9c3e77e282866e850b Mon Sep 17 00:00:00 2001 From: Krzysztof Kotowicz Date: Tue, 23 Jan 2024 17:06:06 +0100 Subject: [PATCH 01/30] Draft integration with Trusted Types, take 2. See https://github.com/w3c/trusted-types/pull/418 and #789. Supercedes PR #809. --- dom.bs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/dom.bs b/dom.bs index 31e95f0c..22c4ff7d 100644 --- a/dom.bs +++ b/dom.bs @@ -6213,8 +6213,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); @@ -6535,6 +6535,10 @@ null), and boolean synchronousCustomElements (default false): attribute attribute to value, run these steps:
    +
  1. Set value to the result of calling Get Trusted Types-compliant attribute + value for attribute, with attribute's element and + value. [[!TRUSTED-TYPES]] +

  2. Let oldValue be attribute's value.

  3. Set attribute's value to value. @@ -6548,6 +6552,11 @@ null), and boolean synchronousCustomElements (default false): steps:

      +
    1. Set attribute's + value to the result of calling Get Trusted Types-compliant attribute value + for attribute, with element and attribute's value. + [[!TRUSTED-TYPES]] +

    2. Append attribute to element's attribute list. @@ -6576,6 +6585,11 @@ steps: attribute oldAttr with an attribute newAttr, run these steps:

        +
      1. Set newAttr's + value to the result of calling Get Trusted Types-compliant attribute value + for newAttr, with oldAttr's element and newAttr's + value.[[!TRUSTED-TYPES]] +

      2. Replace oldAttr by newAttr in oldAttr's element's attribute list. @@ -6662,7 +6676,7 @@ string namespace (default null):

        To set an attribute value given an -element element, a string localName, a string value, +element element, a string localName, a string or TrustedType value, an optional null or string prefix (default null), and an optional null or string namespace (default null): @@ -6673,7 +6687,7 @@ an optional null or string prefix (default null), and an optional nul

      3. If attribute is null, create an attribute whose namespace is namespace, namespace prefix is prefix, - local name is localName, value is value, and + local name is localName, value is stringified value, and node document is element's node document, then append this attribute to element, and then return. @@ -6941,7 +6955,7 @@ method steps are:
      4. If attribute is null, create an attribute whose local name is qualifiedName, value is - value, and node document is this's node document, + stringified value, and node document is this's node document, then append this attribute to this, and then return.

      5. Change attribute to value. From 8b8555f1678297021d4332f647281c27204166b7 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotowicz Date: Wed, 24 Jan 2024 17:05:14 +0100 Subject: [PATCH 02/30] Added integration in 'set an attribute value'. --- dom.bs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/dom.bs b/dom.bs index 22c4ff7d..847f7ce2 100644 --- a/dom.bs +++ b/dom.bs @@ -6685,12 +6685,27 @@ an optional null or string prefix (default null), and an optional nul getting an attribute given namespace, localName, and element. -

      6. If attribute is null, create an attribute whose namespace is - namespace, namespace prefix is prefix, - local name is localName, value is stringified value, and - node document is element's node document, then - append this attribute to element, and then - return. +
      7. If attribute is null, then: + +

          +
        1. Set attribute to a new attribute whose namespace is + namespace, namespace prefix is prefix, + local name is localName and + node document is element's node document. + +

        2. Set attribute's value to the result of calling Get Trusted Types-compliant attribute + value for attribute, with element and + value. [[!TRUSTED-TYPES]] + +

        3. Append attribute to element's + attribute list. + +

        4. Set attribute's element to element. + +

        5. Handle attribute changes for attribute with element, null, and + attribute's value. +

        6. Return. +

      8. Change attribute to value.

      From 952f576f3ec78ad48e6f9d2f44e3a90e3bc04646 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotowicz Date: Wed, 24 Jan 2024 17:59:03 +0100 Subject: [PATCH 03/30] Removed stringification. --- dom.bs | 59 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/dom.bs b/dom.bs index 847f7ce2..6f67153a 100644 --- a/dom.bs +++ b/dom.bs @@ -6535,13 +6535,9 @@ null), and boolean synchronousCustomElements (default false): attribute attribute to value, run these steps:
        -
      1. Set value to the result of calling Get Trusted Types-compliant attribute - value for attribute, with attribute's element and - value. [[!TRUSTED-TYPES]] -

      2. Let oldValue be attribute's value.

      3. -
      4. Set attribute's value to value. +

      5. Validate and set attribute value value for attribute, with attribute's element.

      6. Handle attribute changes for attribute with attribute's element, oldValue, and value. @@ -6552,11 +6548,6 @@ null), and boolean synchronousCustomElements (default false): steps:

          -
        1. Set attribute's - value to the result of calling Get Trusted Types-compliant attribute value - for attribute, with element and attribute's value. - [[!TRUSTED-TYPES]] -

        2. Append attribute to element's attribute list. @@ -6585,11 +6576,6 @@ steps: attribute oldAttr with an attribute newAttr, run these steps:

            -
          1. Set newAttr's - value to the result of calling Get Trusted Types-compliant attribute value - for newAttr, with oldAttr's element and newAttr's - value.[[!TRUSTED-TYPES]] -

          2. Replace oldAttr by newAttr in oldAttr's element's attribute list. @@ -6603,6 +6589,14 @@ steps: value.

          +

          To validate and set attribute value value for an attribute attribute, with element element, run these steps: + +

            +
          1. Let validValue be the result of calling Get Trusted Types-compliant attribute value + for attribute, with element and value.[[!TRUSTED-TYPES]] +

          2. Set attribute's value to validValue. +

          +
          @@ -6665,6 +6659,8 @@ string namespace (default null):

        3. If oldAttr is attr, return attr. +

        4. Validate and set attribute value newAttr's value for newAttr with element. +

        5. If oldAttr is non-null, then replace oldAttr with attr. @@ -6685,7 +6681,12 @@ an optional null or string prefix (default null), and an optional nul getting an attribute given namespace, localName, and element. -

        6. If attribute is null, then: +

        7. 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.
          1. Set attribute to a new attribute whose namespace is @@ -6693,18 +6694,10 @@ an optional null or string prefix (default null), and an optional nul local name is localName and node document is element's node document. -

          2. Set attribute's value to the result of calling Get Trusted Types-compliant attribute - value for attribute, with element and - value. [[!TRUSTED-TYPES]] +

          3. Validate and set attribute value value for attribute with element. -

          4. Append attribute to element's - attribute list. - -

          5. Set attribute's element to element. - -

          6. Handle attribute changes for attribute with element, null, and - attribute's value. -

          7. Return. +

          8. Append attribute to element +

          9. Return.

        8. Change attribute to value. @@ -6968,10 +6961,14 @@ method steps are: and null otherwise. -

        9. If attribute is null, create an attribute whose - local name is qualifiedName, value is - stringified value, and node document is this's node document, - then append this attribute to this, and then return. +

        10. If attribute is null, then: +

            +
          1. Set attribute to a new attribute whose + local name is qualifiedName and node document is this's node document. +

          2. Validate and set attribute value value for attribute, with this. +

          3. Append attribute to this. +
          4. Return. +

        11. Change attribute to value.

        From 588bd9fe8e91a37c4202d06e85bdc1f44b8cde96 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotowicz Date: Thu, 25 Jan 2024 12:08:40 +0100 Subject: [PATCH 04/30] Fixed formatting. --- dom.bs | 56 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/dom.bs b/dom.bs index 6f67153a..3956fb70 100644 --- a/dom.bs +++ b/dom.bs @@ -6537,7 +6537,8 @@ null), and boolean synchronousCustomElements (default false):
        1. Let oldValue be attribute's value.

        2. -
        3. Validate and set attribute value value for attribute, with attribute's element. +

        4. Validate and set attribute value value for attribute, with + attribute's element.

        5. Handle attribute changes for attribute with attribute's element, oldValue, and value. @@ -6589,13 +6590,17 @@ steps: value.

        -

        To validate and set attribute value value for an attribute attribute, with element element, run these steps: +

        To validate and set attribute value +value for an attribute attribute, with element +element, run these steps: + +

          +
        1. Let validValue be the result of calling + Get Trusted Types-compliant attribute value for attribute, with + element and value. [[!TRUSTED-TYPES]] -

            -
          1. Let validValue be the result of calling Get Trusted Types-compliant attribute value - for attribute, with element and value.[[!TRUSTED-TYPES]]

          2. Set attribute's value to validValue. -

          +

        @@ -6659,7 +6664,8 @@ string namespace (default null):

      7. If oldAttr is attr, return attr. -

      8. Validate and set attribute value newAttr's value for newAttr with element. +

      9. Validate and set attribute value newAttr's value for + newAttr with element.

      10. If oldAttr is non-null, then replace oldAttr with attr. @@ -6672,9 +6678,9 @@ string namespace (default null):

        To set an attribute value given an -element element, a string localName, a string or TrustedType 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), and an optional null +or string namespace (default null):

        1. Let attribute be the result of @@ -6691,12 +6697,14 @@ an optional null or string prefix (default null), and an optional nul
          1. Set attribute to a new attribute whose namespace is namespace, namespace prefix is prefix, - local name is localName and - node document is element's node document. + local name is localName and node document is + element's node document. + +

          2. Validate and set attribute value value for attribute with + element. -

          3. Validate and set attribute value value for attribute with element. +

          4. Append attribute to element. -

          5. Append attribute to element

          6. Return.

          @@ -6962,13 +6970,19 @@ method steps are:
        2. If attribute is null, then: -

            -
          1. Set attribute to a new attribute whose - local name is qualifiedName and node document is this's node document. -

          2. Validate and set attribute value value for attribute, with this. -

          3. Append attribute to this. -
          4. Return. -

          + +
            +
          1. Set attribute to a new attribute whose local name is + qualifiedName and node document is this's + node document. + +

          2. Validate and set attribute value value for attribute, + with this. + +

          3. Append attribute to this. + +

          4. Return. +

        3. Change attribute to value.

        From 72cf8f92a3f14f61ab9c2bbf70ca59d45ca29bd8 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotowicz Date: Thu, 25 Jan 2024 15:09:01 +0100 Subject: [PATCH 05/30] Fixed copy-paste error in setAttribute() and indentation. --- dom.bs | 54 +++++++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/dom.bs b/dom.bs index 3956fb70..12242d92 100644 --- a/dom.bs +++ b/dom.bs @@ -6591,8 +6591,8 @@ steps:

      To validate and set attribute value -value for an attribute attribute, with element -element, run these steps: +{{TrustedType}} or a string value for an attribute attribute, with +element element:

      1. Let validValue be the result of calling @@ -6687,26 +6687,21 @@ or string namespace (default null): 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. - -
          -
        1. Set attribute to a new attribute whose namespace is - namespace, namespace prefix is prefix, - local name is localName and node document is - element's node document. +

        2. +

          If attribute is null, then: +

            +
          1. Set attribute to a new attribute whose namespace is + namespace, namespace prefix is prefix, + local name is localName and node document is + element's node document. -

          2. Validate and set attribute value value for attribute with - element. +

          3. Validate and set attribute value value for attribute with + element. -

          4. Append attribute to element. +

          5. Append attribute to element. -

          6. Return. -

          +
        3. Return. +

      3. Change attribute to value.

      @@ -6969,20 +6964,21 @@ method steps are: and null otherwise. -
    3. If attribute is null, then: +

    4. +

      If attribute is null, then: -

        -
      1. Set attribute to a new attribute whose local name is - qualifiedName and node document is this's - node document. +

          +
        1. Set attribute to a new attribute whose local name is + qualifiedName and node document is this's + node document. -

        2. Validate and set attribute value value for attribute, - with this. +

        3. Validate and set attribute value value for attribute, + with this. -

        4. Append attribute to this. +

        5. Append attribute to this. -

        6. Return. -

        +
      2. Return. +

    5. Change attribute to value.

    From cb2fdbbe3548d662b46204f10e4ba921655e8fb0 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 28 Mar 2024 10:54:57 +0000 Subject: [PATCH 06/30] Fix build --- dom.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom.bs b/dom.bs index 12242d92..7fd3f6d7 100644 --- a/dom.bs +++ b/dom.bs @@ -6596,7 +6596,7 @@ steps:
    1. Let validValue be the result of calling - Get Trusted Types-compliant attribute value for attribute, with + get Trusted Types-compliant attribute value for attribute, with element and value. [[!TRUSTED-TYPES]]

    2. Set attribute's value to validValue. From 2a00536fc7e5636afbb0b31adacb4b1af8bbffd1 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 28 Mar 2024 11:52:58 +0000 Subject: [PATCH 07/30] Change code to pass sink values through to TT code. --- dom.bs | 63 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/dom.bs b/dom.bs index 7fd3f6d7..40e212e5 100644 --- a/dom.bs +++ b/dom.bs @@ -4401,7 +4401,7 @@ empty string instead, and then do as described below, switching on the interface

      {{Attr}} -

      Set an existing attribute value with this and the given value. +

      Set an existing attribute value with this, the given value, and "Node nodeValue".

      {{CharacterData}}

      Replace data with node this, offset 0, count this's @@ -4454,7 +4454,8 @@ do as defined below, switching on the interface node implements

      String replace all with value within node.

      {{Attr}} -

      Set an existing attribute value with node and value. +

      Set an existing attribute value with node, value and + "Node textContent".

      {{CharacterData}}

      Replace data with node node, offset 0, count node's @@ -6532,13 +6533,13 @@ null), and boolean synchronousCustomElements (default false):

    To change an -attribute attribute to value, run these steps: +attribute attribute to value, with string sink, run these steps:

    1. Let oldValue be attribute's value.

    2. Validate and set attribute value value for attribute, with - attribute's element. + attribute's element, and sink.

    3. Handle attribute changes for attribute with attribute's element, oldValue, and value. @@ -6592,12 +6593,12 @@ steps:

      To validate and set attribute value {{TrustedType}} or a string value for an attribute attribute, with -element element: +element element, and string sink:

      1. Let validValue be the result of calling get Trusted Types-compliant attribute value for attribute, with - element and value. [[!TRUSTED-TYPES]] + element, value, and sink. [[!TRUSTED-TYPES]]

      2. Set attribute's value to validValue.

      @@ -6651,7 +6652,8 @@ string namespace (default null):

      To set an attribute given an -attribute attr and an element element: +attribute attr, an element element, +and a string sink:

      1. If attr's element is neither null nor element, @@ -6665,7 +6667,7 @@ string namespace (default null):

      2. If oldAttr is attr, return attr.

      3. Validate and set attribute value newAttr's value for - newAttr with element. + newAttr with element, and sink.

      4. If oldAttr is non-null, then replace oldAttr with attr. @@ -6679,8 +6681,8 @@ string namespace (default null):

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

        1. Let attribute be the result of @@ -6696,14 +6698,14 @@ or string namespace (default null): element's node document.
        2. Validate and set attribute value value for attribute with - element. + element, and sink.

        3. Append attribute to element.

        4. Return.

        -
      5. Change attribute to value. +

      6. Change attribute to value, with sink.

      @@ -6973,14 +6975,14 @@ method steps are: node document.
    4. Validate and set attribute value value for attribute, - with this. + with this and "Element setAttribute".

    5. Append attribute to this.

    6. Return.

    -
  4. Change attribute to value. +

  5. Change attribute to value, with "Element setAttribute".

The @@ -6992,7 +6994,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. + and also prefix and namespace, and "Element setAttributeNS".

    The @@ -7078,10 +7080,13 @@ method steps are to return the result of getting an attribute given namespace, localName, and this. -

    The setAttributeNode(attr) and -setAttributeNodeNS(attr) methods steps are to +

    The setAttributeNode(attr) methods steps are to return the result of setting an attribute given attr and -this. +this, and "Element setAttributeNode". + +

    The setAttributeNodeNS(attr) methods steps are to +return the result of setting an attribute given attr, +this, and "Element setAttributeNodeNS".

    The removeAttributeNode(attr) method steps are: @@ -7436,10 +7441,13 @@ method steps are to return the result of getting an attribute given namespace, localName, and element. -

    The setNamedItem(attr) and -setNamedItemNS(attr) method steps are -to return the result of setting an attribute given attr and -element. +

    The setNamedItem(attr) method steps are +to return the result of setting an attribute given attr, +element, and "NamedNodeMap setNamedItem". + +

    The setNamedItemNS(attr) method steps are +to return the result of setting an attribute given attr, +element, and "NamedNodeMap setNamedItemNS".

    The removeNamedItem(qualifiedName) method steps are: @@ -7543,18 +7551,19 @@ null.

    The value getter steps are to return this's value. -

    To set an existing attribute value, given an attribute attribute and -string value, run these steps: +

    To set an existing attribute value, given an attribute attribute, +string value, and string sink, run these steps:

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

    2. Otherwise, change attribute to value. +

    3. Otherwise, change attribute to value, + with sink.

    -

    The {{Attr/value}} setter steps are to set an existing attribute value with this -and the given value. +

    The {{Attr/value}} setter steps are to set an existing attribute value with this, +the given value, and "Attr value".


    From 316965cee8bf6af7a73a5071ecb66cf4515eebdb Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Wed, 10 Apr 2024 16:43:01 +0100 Subject: [PATCH 08/30] Move validate and set attribute into append an attribute --- dom.bs | 68 +++++++++++++++++++++++++--------------------------------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/dom.bs b/dom.bs index 40e212e5..a950d588 100644 --- a/dom.bs +++ b/dom.bs @@ -6546,10 +6546,14 @@ null), and boolean synchronousCustomElements (default false):

    To append an -attribute attribute to an element element, run these -steps: +attribute attribute to an element element, with optional +string sink (default ""), run these steps:

      +
    1. If sink is not an empty string Validate and set attribute value + attribute's value for attribute with element, + and sink. +

    2. Append attribute to element's attribute list. @@ -6666,13 +6670,18 @@ and a string sink:

    3. If oldAttr is attr, return attr. -

    4. Validate and set attribute value newAttr's value for - newAttr with element, and sink. +

    5. +

      If oldAttr is non-null, then:

      + + -
    6. Otherwise, append attr to element. +

    7. Otherwise, append attr to element + with sink.

    8. Return oldAttr.

    @@ -6689,21 +6698,12 @@ or string namespace (default null), and an optional string sink< getting an attribute given namespace, localName, and element. -
  • -

    If attribute is null, then: -

      -
    1. Set attribute to a new attribute whose namespace is - namespace, namespace prefix is prefix, - local name is localName and node document is - element's node document. - -

    2. Validate and set attribute value value for attribute with - element, and sink. - -

    3. Append attribute to element. - -

    4. Return. -

    +
  • 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 with + sink, and then return.
  • Change attribute to value, with sink. @@ -6966,21 +6966,11 @@ method steps are: and null otherwise. -

  • -

    If attribute is null, then: - -

      -
    1. Set attribute to a new attribute whose local name is - qualifiedName and node document is this's - node document. - -

    2. Validate and set attribute value value for attribute, - with this and "Element setAttribute". - -

    3. Append attribute to this. - -

    4. Return. -

    +
  • 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 with + "Element setAttribute", and then return.

  • Change attribute to value, with "Element setAttribute". @@ -7043,8 +7033,8 @@ method steps are:

  • If force is not given or is true, create an attribute whose local name is qualifiedName, value is the empty string, and node document is this's node document, then - append this attribute to this, and then return - true. + append this attribute to this with + "Element toggleAttribute", and then return true.

  • Return false. From 8569042b5cae3b698971e6be185aaa1c841eedbf Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 11 Apr 2024 13:12:42 +0100 Subject: [PATCH 09/30] Remove sink values from spec --- dom.bs | 89 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/dom.bs b/dom.bs index a950d588..931feb34 100644 --- a/dom.bs +++ b/dom.bs @@ -4401,7 +4401,7 @@ empty string instead, and then do as described below, switching on the interface

    {{Attr}} -

    Set an existing attribute value with this, the given value, and "Node nodeValue". +

    Set an existing attribute value with this, the given value.

    {{CharacterData}}

    Replace data with node this, offset 0, count this's @@ -4454,8 +4454,7 @@ do as defined below, switching on the interface node implements

    String replace all with value within node.

    {{Attr}} -

    Set an existing attribute value with node, value and - "Node textContent". +

    Set an existing attribute value with node, value.

    {{CharacterData}}

    Replace data with node node, offset 0, count node's @@ -4631,7 +4630,8 @@ and an optional document docume

  • Let copyAttribute be the result of cloning a single node given attribute and document. -

  • Append copyAttribute to copy. +

  • Append copyAttribute to copy, + with false. @@ -6533,26 +6533,36 @@ null), and boolean synchronousCustomElements (default false):

    To change an -attribute attribute to value, with string sink, run these steps: +attribute attribute to value, run these steps:

    1. Let oldValue be attribute's value.

    2. Validate and set attribute value value for attribute, with - attribute's element, and sink. + attribute's element. -

    3. Handle attribute changes for attribute with attribute's - element, oldValue, and value. +

    4. If attribute's element has + an attribute attribute, then handle attribute changes for + attribute with attribute's element, oldValue, and + value. + +

    5. Otherwise, throw an "{{InvalidStateError!!exception}}" {{DOMException}}.

    To append an attribute attribute to an element element, with optional -string sink (default ""), run these steps: +boolean validate (default true), run these steps:

      -
    1. If sink is not an empty string Validate and set attribute value - attribute's value for attribute with element, - and sink. +

    2. +

      If validate, then: +

        +
      1. Validate and set attribute value + attribute's value for attribute with element. + +

      2. If element has an attribute + attribute, then throw an "{{InvalidStateError!!exception}}" {{DOMException}}. +

    3. Append attribute to element's attribute list. @@ -6597,12 +6607,12 @@ string sink (default ""), run these steps:

      To validate and set attribute value {{TrustedType}} or a string value for an attribute attribute, with -element element, and string sink: +element element:

      1. Let validValue be the result of calling get Trusted Types-compliant attribute value for attribute, with - element, value, and sink. [[!TRUSTED-TYPES]] + element, value. [[!TRUSTED-TYPES]]

      2. Set attribute's value to validValue.

      @@ -6656,8 +6666,7 @@ string namespace (default null):

      To set an attribute given an -attribute attr, an element element, -and a string sink: +attribute attr, an element element.

      1. If attr's element is neither null nor element, @@ -6675,13 +6684,16 @@ and a string sink:

        -
      2. Otherwise, append attr to element - with sink. +

      3. Otherwise, append attr to element.

      4. Return oldAttr.

      @@ -6691,7 +6703,7 @@ and a string sink:

      To set an attribute value given an 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 string sink (default ""): +or string namespace (default null):

      1. Let attribute be the result of @@ -6702,10 +6714,9 @@ or string namespace (default null), and an optional string sink< 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 with - sink, and then return. + append this attribute to element, and then return. -
      2. Change attribute to value, with sink. +

      3. Change attribute to value.

      @@ -6966,13 +6977,12 @@ method steps are: and null otherwise. -
    4. 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 with - "Element setAttribute", and then return. +

    5. 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. -

    6. Change attribute to value, with "Element setAttribute". +

    7. Change attribute to value.

    The @@ -6984,7 +6994,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, and "Element setAttributeNS". + and also prefix and namespace.

    The @@ -7033,8 +7043,8 @@ method steps are:

  • If force is not given or is true, create an attribute whose local name is qualifiedName, value is the empty string, and node document is this's node document, then - append this attribute to this with - "Element toggleAttribute", and then return true. + append this attribute to this, + and then return true.

  • Return false. @@ -7072,11 +7082,11 @@ method steps are to return the result of

    The setAttributeNode(attr) methods steps are to return the result of setting an attribute given attr and -this, and "Element setAttributeNode". +this.

    The setAttributeNodeNS(attr) methods steps are to return the result of setting an attribute given attr, -this, and "Element setAttributeNodeNS". +this.

    The removeAttributeNode(attr) method steps are: @@ -7433,11 +7443,11 @@ method steps are to return the result of

    The setNamedItem(attr) method steps are to return the result of setting an attribute given attr, -element, and "NamedNodeMap setNamedItem". +element.

    The setNamedItemNS(attr) method steps are to return the result of setting an attribute given attr, -element, and "NamedNodeMap setNamedItemNS". +element.

    The removeNamedItem(qualifiedName) method steps are: @@ -7542,14 +7552,13 @@ null. value.

    To set an existing attribute value, given an attribute attribute, -string value, and string sink, run these steps: +string value, run these steps:

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

    2. Otherwise, change attribute to value, - with sink. +

    3. Otherwise, change attribute to value.

    The {{Attr/value}} setter steps are to set an existing attribute value with this, From 7027be5e75faea028f42960b02e336668747b048 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Mon, 22 Apr 2024 13:19:52 +0100 Subject: [PATCH 10/30] Revert changes to setAttributeNode and setAttributeNodeNS method steps --- dom.bs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/dom.bs b/dom.bs index 931feb34..3ae0c729 100644 --- a/dom.bs +++ b/dom.bs @@ -7080,14 +7080,11 @@ method steps are to return the result of getting an attribute given namespace, localName, and this. -

    The setAttributeNode(attr) methods steps are to +

    The setAttributeNode(attr) and +setAttributeNodeNS(attr) methods steps are to return the result of setting an attribute given attr and this. -

    The setAttributeNodeNS(attr) methods steps are to -return the result of setting an attribute given attr, -this. -

    The removeAttributeNode(attr) method steps are: From ac21ffe18dc3045ad3d1f669df2bb8e1ea084b7e Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Mon, 22 Apr 2024 14:13:29 +0100 Subject: [PATCH 11/30] Remove throw from set an attribute and move TT check down to replace an attribute --- dom.bs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/dom.bs b/dom.bs index 3ae0c729..aba481c4 100644 --- a/dom.bs +++ b/dom.bs @@ -6592,6 +6592,9 @@ boolean validate (default true), run these steps: attribute oldAttr with an attribute newAttr, run these steps:

      +
    1. Validate and set attribute value newAttr's value for + newAttr with oldAttr's element. +

    2. Replace oldAttr by newAttr in oldAttr's element's attribute list. @@ -6677,21 +6680,8 @@ string namespace (default null):

      attr's namespace, attr's local name, and element. -
    3. If oldAttr is attr, return attr. - -

    4. -

      If oldAttr is non-null, then:

      - - +
    5. If oldAttr is non-null, then replace + oldAttr with attr.

    6. Otherwise, append attr to element. From 03dc3feacd30b15cb018c72ce417c1bb3e908cd9 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Mon, 22 Apr 2024 16:44:45 +0100 Subject: [PATCH 12/30] Revert unneeded changes --- dom.bs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/dom.bs b/dom.bs index aba481c4..e1774d62 100644 --- a/dom.bs +++ b/dom.bs @@ -4401,7 +4401,7 @@ empty string instead, and then do as described below, switching on the interface

      {{Attr}} -

      Set an existing attribute value with this, the given value. +

      Set an existing attribute value with this and the given value.

      {{CharacterData}}

      Replace data with node this, offset 0, count this's @@ -7428,12 +7428,9 @@ method steps are to return the result of getting an attribute given namespace, localName, and element. -

      The setNamedItem(attr) method steps are -to return the result of setting an attribute given attr, -element. - -

      The setNamedItemNS(attr) method steps are -to return the result of setting an attribute given attr, +

      The setNamedItem(attr) and +setNamedItemNS(attr) method steps are +to return the result of setting an attribute given attr and element.

      The removeNamedItem(qualifiedName) From ae5ba7a3ee343801686f9aaaed8157036bf1aa30 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Mon, 22 Apr 2024 16:44:55 +0100 Subject: [PATCH 13/30] Address comment --- dom.bs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/dom.bs b/dom.bs index e1774d62..e6dac407 100644 --- a/dom.bs +++ b/dom.bs @@ -4454,7 +4454,7 @@ do as defined below, switching on the interface node implements

      String replace all with value within node.

      {{Attr}} -

      Set an existing attribute value with node, value. +

      Set an existing attribute value with node and value.

      {{CharacterData}}

      Replace data with node node, offset 0, count node's @@ -6538,7 +6538,7 @@ null), and boolean synchronousCustomElements (default false):

      1. Let oldValue be attribute's value.

      2. -
      3. Validate and set attribute value value for attribute, with +

      4. Verify and set attribute value value for attribute, with attribute's element.

      5. If attribute's element has @@ -6555,9 +6555,9 @@ boolean validate (default true), run these steps:

        1. -

          If validate, then: +

          If validate is true, then:

            -
          1. Validate and set attribute value +

          2. Verify and set attribute value attribute's value for attribute with element.

          3. If element has an attribute @@ -6592,7 +6592,7 @@ boolean validate (default true), run these steps: attribute oldAttr with an attribute newAttr, run these steps:

              -
            1. Validate and set attribute value newAttr's value for +

            2. Verify and set attribute value newAttr's value for newAttr with oldAttr's element.

            3. Replace oldAttr by newAttr in oldAttr's @@ -6608,8 +6608,8 @@ boolean validate (default true), run these steps: value.

            -

            To validate and set attribute value -{{TrustedType}} or a string value for an attribute attribute, with +

            To verify and set attribute value +{{TrustedType}} or string value for an attribute attribute, with element element:

              @@ -6669,7 +6669,7 @@ string namespace (default null):

              To set an attribute given an -attribute attr, an element element. +attribute attr and an element element:

              1. If attr's element is neither null nor element, @@ -6704,7 +6704,8 @@ or string namespace (default null): 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. + append this attribute to element, and then + return.

              2. Change attribute to value.

              @@ -7033,8 +7034,8 @@ method steps are:
            1. If force is not given or is true, create an attribute whose local name is qualifiedName, value is the empty string, and node document is this's node document, then - append this attribute to this, - and then return true. + append this attribute to this, and then return + true.

            2. Return false.

            @@ -7535,7 +7536,7 @@ null.

            The value getter steps are to return this's value. -

            To set an existing attribute value, given an attribute attribute, +

            To set an existing attribute value, given an attribute attribute and string value, run these steps:

              @@ -7545,8 +7546,8 @@ string value, run these steps:
            1. Otherwise, change attribute to value.

            -

            The {{Attr/value}} setter steps are to set an existing attribute value with this, -the given value, and "Attr value". +

            The {{Attr/value}} setter steps are to set an existing attribute value with this +and the given value.


            From 3b607afa19df2ca50ce18ff7544083da89a69ead Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Mon, 22 Apr 2024 16:54:01 +0100 Subject: [PATCH 14/30] Add missing and --- dom.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom.bs b/dom.bs index e6dac407..3e7b8920 100644 --- a/dom.bs +++ b/dom.bs @@ -6692,7 +6692,7 @@ string namespace (default null):

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

              From 6726a50fe49d1cb8b84b3b139cb9ab65392c4e37 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Tue, 7 May 2024 16:39:27 +0100 Subject: [PATCH 15/30] Address some comments --- dom.bs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/dom.bs b/dom.bs index 3e7b8920..892267da 100644 --- a/dom.bs +++ b/dom.bs @@ -6541,8 +6541,8 @@ null), and boolean synchronousCustomElements (default false):
            1. Verify and set attribute value value for attribute, with attribute's element. -

            2. If attribute's element has - an attribute attribute, then handle attribute changes for +

            3. If attribute's element + has an attribute, then handle attribute changes for attribute with attribute's element, oldValue, and value. @@ -6550,15 +6550,16 @@ null), and boolean synchronousCustomElements (default false):

            To append an -attribute attribute to an element element, with optional -boolean validate (default true), run these steps: +attribute attribute to an element element, with an +optional boolean validate (default true):

            1. -

              If validate is true, then: +

              If validate is true: +

              1. Verify and set attribute value - attribute's value for attribute with element. + attribute's value for attribute, with element.

              2. If element has an attribute attribute, then throw an "{{InvalidStateError!!exception}}" {{DOMException}}. @@ -6593,7 +6594,7 @@ boolean validate (default true), run these steps:

                1. Verify and set attribute value newAttr's value for - newAttr with oldAttr's element. + newAttr, with oldAttr's element.

                2. Replace oldAttr by newAttr in oldAttr's element's attribute list. @@ -6608,16 +6609,16 @@ boolean validate (default true), run these steps: value.

                -

                To verify and set attribute value +

                To verify and set attribute value {{TrustedType}} or string value for an attribute attribute, with element element:

                  -
                1. Let validValue be the result of calling +

                2. Let verifiedValue be the result of calling get Trusted Types-compliant attribute value for attribute, with element, value. [[!TRUSTED-TYPES]] -

                3. Set attribute's value to validValue. +

                4. Set attribute's value to verifiedValue.


                From 93251d0ea7679f8f940152104ca0fb8725e0ba62 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Tue, 7 May 2024 16:41:29 +0100 Subject: [PATCH 16/30] Re-add early return --- dom.bs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dom.bs b/dom.bs index 892267da..1ac29970 100644 --- a/dom.bs +++ b/dom.bs @@ -6681,6 +6681,8 @@ string namespace (default null):

                attr's namespace, attr's local name, and element. +
              3. If oldAttr is attr, return attr. +

              4. If oldAttr is non-null, then replace oldAttr with attr. From 0fbb13cca9765b3290e1a14ad88fb50081dc3a50 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Tue, 7 May 2024 16:49:03 +0100 Subject: [PATCH 17/30] Change dfn to use given rather than with --- dom.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dom.bs b/dom.bs index 1ac29970..e8486db0 100644 --- a/dom.bs +++ b/dom.bs @@ -6610,8 +6610,8 @@ optional boolean validate (default true):

              To verify and set attribute value -{{TrustedType}} or string value for an attribute attribute, with -element element: +{{TrustedType}} or string value for an attribute attribute, given an +Element element:

              1. Let verifiedValue be the result of calling From e9280a47b7309119d45af5953242f412e55977ee Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 16 May 2024 16:38:19 +0100 Subject: [PATCH 18/30] Update how the enforcement is done --- dom.bs | 108 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 43 deletions(-) diff --git a/dom.bs b/dom.bs index e8486db0..1688256a 100644 --- a/dom.bs +++ b/dom.bs @@ -4630,8 +4630,7 @@ and an optional document docume

              2. Let copyAttribute be the result of cloning a single node given attribute and document. -

              3. Append copyAttribute to copy, - with false. +

              4. Append copyAttribute to copy.

            @@ -6538,33 +6537,17 @@ null), and boolean synchronousCustomElements (default false):
            1. Let oldValue be attribute's value.

            2. -
            3. Verify and set attribute value value for attribute, with - attribute's element. +

            4. Set attribute's value to value. -

            5. If attribute's element - has an attribute, then handle attribute changes for - attribute with attribute's element, oldValue, and - value. - -

            6. Otherwise, throw an "{{InvalidStateError!!exception}}" {{DOMException}}. +

            7. Handle attribute changes for attribute with attribute's + element, oldValue, and value.

            To append an -attribute attribute to an element element, with an -optional boolean validate (default true): +attribute attribute to an element element, run these +steps:

              -
            1. -

              If validate is true: - -

                -
              1. Verify and set attribute value - attribute's value for attribute, with element. - -

              2. If element has an attribute - attribute, then throw an "{{InvalidStateError!!exception}}" {{DOMException}}. -

              -
            2. Append attribute to element's attribute list. @@ -6593,9 +6576,6 @@ optional boolean validate (default true): attribute oldAttr with an attribute newAttr, run these steps:

                -
              1. Verify and set attribute value newAttr's value for - newAttr, with oldAttr's element. -

              2. Replace oldAttr by newAttr in oldAttr's element's attribute list. @@ -6609,16 +6589,14 @@ optional boolean validate (default true): value.

              -

              To verify and set attribute value +

              To verify attribute value {{TrustedType}} or string value for an attribute attribute, given an Element element:

                -
              1. Let verifiedValue be the result of calling +

              2. Return the result of calling get Trusted Types-compliant attribute value for attribute, with element, value. [[!TRUSTED-TYPES]] - -

              3. Set attribute's value to verifiedValue.


              @@ -6683,6 +6661,11 @@ string namespace (default null):

            3. If oldAttr is attr, return attr. +

            4. Let verifiedValue be the result of calling verify attribute value + attr's value for attr, with element. + +

            5. Set attr's value to verifiedValue. +

            6. If oldAttr is non-null, then replace oldAttr with attr. @@ -6703,14 +6686,30 @@ or string namespace (default null): getting an attribute given namespace, localName, and element. -

            7. 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. +
            8. Let attributeExists be false if attribute is null, and true otherwise. + +

            9. If attributeExists is false, 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. + +

            10. Let verifiedValue be the result of calling verify attribute value + value for attribute, with element. -

            11. Change attribute to value. +

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

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

            14. Otherwise: +

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

              2. Append this attribute to + element. +

            @@ -6971,12 +6970,29 @@ method steps are: and null otherwise. -
          4. 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. +

          5. Let attributeExists be false if attribute is null, and true otherwise. + +

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

          7. Let verifiedValue be the result of calling verify attribute value + value for attribute, with this. + +

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

          9. Change attribute to value. +

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

          11. Otherwise: +

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

            2. Append this attribute to + element. +

          The @@ -7546,7 +7562,13 @@ string value, run these steps:

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

        3. Otherwise, change attribute to value. +

        4. Otherwise: +

            +
          1. Let verifiedValue be the result of calling verify attribute value + value for attribute, with this. + +

          2. Change attribute to verifiedValue. +

        The {{Attr/value}} setter steps are to set an existing attribute value with this From daa8d86e9f75f4440279173561923c0a5ab54e97 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 16 May 2024 17:38:21 +0100 Subject: [PATCH 19/30] Add tentative enforcement for toggleAttribute --- dom.bs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dom.bs b/dom.bs index 1688256a..7cec8f27 100644 --- a/dom.bs +++ b/dom.bs @@ -7050,11 +7050,17 @@ method steps are:

        If attribute is null:

          -
        1. If force is not given or is true, create an attribute whose +

        2. Set attribute to an attribute whose local name is qualifiedName, value is the empty - string, and node document is this's node document, then - append this attribute to this, and then return - true. + string, and node document is this's node document. + +

        3. Let verifiedValue be the result of calling verify attribute value + attribute's value for attribute, with this. + +

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

        5. If force is not given or is true, then append + this attribute to this, and then return true.

        6. Return false.

        From f8e9015b69d041235645e113e7974b8eba6942a6 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 16 May 2024 17:57:36 +0100 Subject: [PATCH 20/30] Update enforcement for toggleAttribute to match behaviour observed in Chrome. --- dom.bs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/dom.bs b/dom.bs index 7cec8f27..8d529f11 100644 --- a/dom.bs +++ b/dom.bs @@ -7050,6 +7050,8 @@ method steps are:

        If attribute is null:

          +
        1. If force is false, return false. +

        2. Set attribute to an attribute whose local name is qualifiedName, value is the empty string, and node document is this's node document. @@ -7057,12 +7059,20 @@ method steps are:

        3. Let verifiedValue be the result of calling verify attribute value attribute's value for attribute, with this. -

        4. Set attribute's value to verifiedValue. +

        5. Let existingAttribute be the first attribute in this's + attribute list whose qualified name is qualifiedName, + and null otherwise. + +

        6. If existingAttribute is null: +

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

          2. Append attribute to this. -

          3. If force is not given or is true, then append - this attribute to this, and then return true. +

          4. Return true. +

          -
        7. Return false. +

        8. Set existingAttribute's value to verifiedValue.

      6. Otherwise, if force is not given or is false, From 7b4a995b20e97c4e0d87cac6f543944f4007fe8e Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Tue, 11 Jun 2024 13:33:57 +0200 Subject: [PATCH 21/30] Revert "Update enforcement for toggleAttribute to match behaviour observed in Chrome." This reverts commit 2f00466aaa9ea9f01aa88dbe779cd1f02ffc437f. --- dom.bs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/dom.bs b/dom.bs index 8d529f11..7cec8f27 100644 --- a/dom.bs +++ b/dom.bs @@ -7050,8 +7050,6 @@ method steps are:

        If attribute is null:

          -
        1. If force is false, return false. -

        2. Set attribute to an attribute whose local name is qualifiedName, value is the empty string, and node document is this's node document. @@ -7059,20 +7057,12 @@ method steps are:

        3. Let verifiedValue be the result of calling verify attribute value attribute's value for attribute, with this. -

        4. Let existingAttribute be the first attribute in this's - attribute list whose qualified name is qualifiedName, - and null otherwise. - -

        5. If existingAttribute is null: -

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

          2. Append attribute to this. +

          3. Set attribute's value to verifiedValue. -

          4. Return true. -

          +
        6. If force is not given or is true, then append + this attribute to this, and then return true. -

        7. Set existingAttribute's value to verifiedValue. +

        8. Return false.

      7. Otherwise, if force is not given or is false, From 0b3bc4827e0471448525fdd9e333b5ebda278b3b Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Tue, 11 Jun 2024 13:35:44 +0200 Subject: [PATCH 22/30] Revert "Add tentative enforcement for toggleAttribute" This reverts commit 6e409647b112fe96d12583b8814d9f0a9980149e. --- dom.bs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/dom.bs b/dom.bs index 7cec8f27..1688256a 100644 --- a/dom.bs +++ b/dom.bs @@ -7050,17 +7050,11 @@ method steps are:

        If attribute is null:

          -
        1. Set attribute to an attribute whose +

        2. If force is not given or is true, create an attribute whose local name is qualifiedName, value is the empty - string, and node document is this's node document. - -

        3. Let verifiedValue be the result of calling verify attribute value - attribute's value for attribute, with this. - -

        4. Set attribute's value to verifiedValue. - -

        5. If force is not given or is true, then append - this attribute to this, and then return true. + string, and node document is this's node document, then + append this attribute to this, and then return + true.

        6. Return false.

        From d96fb19a0c4c0f2e9511088fdd74da214cb0cd4c Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 13 Jun 2024 17:21:58 +0200 Subject: [PATCH 23/30] Reintroduce infrastructure changes --- dom.bs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/dom.bs b/dom.bs index 1688256a..996e6697 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]] @@ -6678,8 +6680,9 @@ string namespace (default null):

        To set an attribute value given an element element, a string localName, a string or {{TrustedType}} -value, an optional null or string prefix (default null), and an optional null -or string namespace (default null): +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 @@ -6694,11 +6697,17 @@ or string namespace (default null): value, and node document is element's node document. -
        2. Let verifiedValue be the result of calling verify attribute value - value for attribute, with element. +

        3. Let verifiedValue be value. + +

        4. If verify is true: +

            +
          1. Set verifiedValue to the result of calling verify attribute value + value for attribute, with element. -

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

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

          +
        5. If attributeExists is true, change attribute to verifiedValue. @@ -7004,7 +7013,7 @@ method steps are: passing namespace and qualifiedName to validate and extract.

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

        The From 73fa48257a6137909a06e84d161937816654404c Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 6 Feb 2025 15:51:39 +0000 Subject: [PATCH 24/30] Add step to verify that the attr hasn't been assigned to another element by the default policy --- dom.bs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dom.bs b/dom.bs index 996e6697..a631b40c 100644 --- a/dom.bs +++ b/dom.bs @@ -6668,6 +6668,9 @@ string namespace (default null):

      8. Set attr's value to verifiedValue. +

      9. If attr's element is neither null nor element, + throw an "{{InUseAttributeError!!exception}}" {{DOMException}}. +

      10. If oldAttr is non-null, then replace oldAttr with attr. From fdb686bb298e2bf240084d3fb7e6b07a19076d43 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 6 Feb 2025 15:53:02 +0000 Subject: [PATCH 25/30] Run specfmt --- dom.bs | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/dom.bs b/dom.bs index a631b40c..ae788d87 100644 --- a/dom.bs +++ b/dom.bs @@ -6591,14 +6591,12 @@ steps: value.

      -

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

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

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

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


      @@ -6681,11 +6679,11 @@ string namespace (default null):

      -

      To set an attribute value given an -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): +

      To set an attribute value given an 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 @@ -6719,8 +6717,7 @@ or string namespace (default null), and an optional boolean veri
        1. Set attribute's value to verifiedValue. -

        2. Append this attribute to - element. +

        3. Append this attribute to element.

      @@ -6986,8 +6983,7 @@ method steps are:
    7. If attributeExists is false, set attribute to an attribute whose local name is qualifiedName, value is - value, and node document is this's node - document. + value, and node document is this's node document.

    8. Let verifiedValue be the result of calling verify attribute value value for attribute, with this. @@ -7002,8 +6998,7 @@ method steps are:

      1. Set attribute's value to verifiedValue. -

      2. Append this attribute to - element. +

      3. Append this attribute to element.

    From b0473529b78553e78cedb074fa375471a0f5c489 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 20 Feb 2025 14:47:36 +0000 Subject: [PATCH 26/30] Update set an attribute to verify attribute value as first step --- dom.bs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/dom.bs b/dom.bs index ae788d87..93d7cb94 100644 --- a/dom.bs +++ b/dom.bs @@ -6651,6 +6651,9 @@ string namespace (default null):

    attribute attr and an element element:
      +
    1. Let verifiedValue be the result of calling verify attribute value + attr's value for attr, with element. +

    2. If attr's element is neither null nor element, throw an "{{InUseAttributeError!!exception}}" {{DOMException}}. @@ -6661,19 +6664,13 @@ string namespace (default null):

    3. If oldAttr is attr, return attr. -

    4. Let verifiedValue be the result of calling verify attribute value - attr's value for attr, with element. - -

    5. Set attr's value to verifiedValue. - -

    6. If attr's element is neither null nor element, - throw an "{{InUseAttributeError!!exception}}" {{DOMException}}. -

    7. If oldAttr is non-null, then replace oldAttr with attr.

    8. Otherwise, append attr to element. +

    9. Set attr's value to verifiedValue. +

    10. Return oldAttr.

    From 5f234a4907ed9e97d9694f010b533b3a69803791 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 20 Feb 2025 15:42:59 +0000 Subject: [PATCH 27/30] Update set an existing attribute value If the TT callback changed removed the attr from an element then we set its standalone value and return. If the TT callback changed the attrs element to a different element we now early return. --- dom.bs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dom.bs b/dom.bs index 93d7cb94..5bf802f0 100644 --- a/dom.bs +++ b/dom.bs @@ -7568,8 +7568,16 @@ string value, run these steps:
  • Otherwise:

      -
    1. Let verifiedValue be the result of calling verify attribute value - value for attribute, with this. +

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

    3. Let verifiedValue be the result of calling verify attribute value + value for attribute, with this. + +

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

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

    6. Change attribute to verifiedValue.

    From 6b2fff6b1a8bf524b0904b4c9dbc4c253c0c11f8 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 20 Feb 2025 15:54:38 +0000 Subject: [PATCH 28/30] Address editorial feedback --- dom.bs | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/dom.bs b/dom.bs index 5bf802f0..b290c402 100644 --- a/dom.bs +++ b/dom.bs @@ -6591,12 +6591,12 @@ steps: value. -

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

    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 - for attribute, with element, value. [[!TRUSTED-TYPES]] + given attribute, with element, and value. [[!TRUSTED-TYPES]]


    @@ -6652,7 +6652,7 @@ string namespace (default null):

    1. Let verifiedValue be the result of calling verify attribute value - attr's value for attr, with element. + given attr's value, attr, and element.

    2. If attr's element is neither null nor element, throw an "{{InUseAttributeError!!exception}}" {{DOMException}}. @@ -6687,7 +6687,7 @@ false): getting an attribute given namespace, localName, and element. -

    3. Let attributeExists be false if attribute is null, and true otherwise. +

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

    5. If attributeExists is false, set attribute to an attribute whose namespace is namespace, namespace prefix is @@ -6697,20 +6697,24 @@ false):

    6. Let verifiedValue be value. -

    7. If verify is true: +

    8. +

      If verify is true: +

      1. Set verifiedValue to the result of calling verify attribute value - value for attribute, with element. + given value, attribute, and element. -

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

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

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

    10. Otherwise: +

    11. +

      Otherwise: +

      1. Set attribute's value to verifiedValue. @@ -6976,22 +6980,24 @@ method steps are: and null otherwise. -

      2. Let attributeExists be false if attribute is null, and true otherwise. +

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

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

      5. Let verifiedValue be the result of calling verify attribute value - value for attribute, with this. + given value, attribute, and this. -

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

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

      8. If attributeExists is true, change attribute to verifiedValue. -

      9. Otherwise: +

      10. +

        Otherwise: +

        1. Set attribute's value to verifiedValue. @@ -7566,12 +7572,14 @@ string value, run these steps:

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

        3. Otherwise: +

        4. +

          Otherwise: +

          1. Let originalElement be attribute's element.

          2. Let verifiedValue be the result of calling verify attribute value - value for attribute, with this. + given value, attribute, and this.

          3. If attribute's element is null, then set attribute's value to value, and return. From 51b09e4efe23bf2365bd5c528e4334e4ffd2e27f Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Mon, 17 Mar 2025 15:12:00 +0000 Subject: [PATCH 29/30] Swap value to verifiedValue --- dom.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom.bs b/dom.bs index b290c402..768a5912 100644 --- a/dom.bs +++ b/dom.bs @@ -7582,7 +7582,7 @@ string value, run these steps: given value, attribute, and this.

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

          5. If attribute's element is not originalElement, then return. From fe27a1dad11e412e8bfd15098b71ac89b72f770d Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Mon, 17 Mar 2025 15:23:11 +0000 Subject: [PATCH 30/30] verifying an attribute value , then set phrasing level wrapping --- dom.bs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/dom.bs b/dom.bs index 768a5912..23d49703 100644 --- a/dom.bs +++ b/dom.bs @@ -6651,8 +6651,9 @@ string namespace (default null):

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

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

            3. If attr's element is neither null nor element, throw an "{{InUseAttributeError!!exception}}" {{DOMException}}. @@ -6676,8 +6677,8 @@ string namespace (default null):

              -

              To set an attribute value given an element element, a string localName, a string or {{TrustedType}} +

              To set an attribute value given an +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): @@ -6689,11 +6690,11 @@ false):

            4. Let attributeExists be false if attribute is null; otherwise true. -

            5. If attributeExists is false, set attribute to an attribute +

            6. 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. + value, and node document is element's + node document.

            7. Let verifiedValue be value. @@ -6701,8 +6702,9 @@ false):

              If verify is true:

                -
              1. Set verifiedValue to the result of calling verify attribute value - given value, attribute, and element. +

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

              3. Set attributeExists to true if element has an attribute attribute; otherwise false. @@ -6982,12 +6984,13 @@ method steps are:

              4. Let attributeExists be false if attribute is null; otherwise true. -

              5. If attributeExists is false, set attribute to an attribute +

              6. 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. -

              7. Let verifiedValue be the result of calling verify attribute value - given value, attribute, and this. +

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

              9. Set attributeExists to true if this has an attribute attribute; otherwise false. @@ -7578,8 +7581,9 @@ string value, run these steps:

                1. Let originalElement be attribute's element. -

                2. Let verifiedValue be the result of calling verify attribute value - given value, attribute, and this. +

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

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