From d20d68b0419128627b87dfd061321338335a56ea Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Thu, 9 Aug 2018 15:51:22 +1000 Subject: [PATCH 01/20] Add logic for reflecting IDREF (single) attributes. --- source | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/source b/source index c127ef318d6..dd01601a878 100644 --- a/source +++ b/source @@ -7218,8 +7218,62 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute return a DOMTokenList object whose associated element is the element in question and whose associated attribute's local name is the name of the attribute in question.

- +

If a reflecting IDL attribute has the type HTMLElement, + or an interface that descends from HTMLElement, + then it must be paired with another reflecting IDL attribute + that has the type DOMString. + The relationship between these two attributes is as follows:

+ +
    +
  1. The attribute which has the type HTMLElement + should be named attrElement, + where the paired DOMString attribute is named + attr.
  2. +
  3. On getting the attr attribute, + the IDL attribute must return the value of the content attribute as normal.
  4. + +
  5. On getting the attrElement attribute, + it must run the following algorithm + (stopping at the first point where a value is returned):
  6. +
      +
    1. If the content attribute corresponding to attr + is absent, then the IDL attribute attrElement must return null.
    2. + +
    3. Let candidate be the element that the + document.getElementById() method + would find when called on the content attribute's element's node document + if it were passed as its argument the current value + of the corresponding content attribute.
    4. + +
    5. If candidate is null, or if it is not type-compatible with the IDL attribute, + then the IDL attribute must return null.
    6. + +
    7. Otherwise, it must return candidate.
    8. +
    +
  7. On setting the attr attribute, + the content attribute must be set to the specified value.
  8. + +
  9. On setting the attrElement attribute, + it must run the following algorithm:
  10. +
      +
    1. Let id be the empty string.
    2. +
    3. If the given element has an id attribute, + and has the same tree as the element of the attribute being set, + and the given element is the first element in that tree + whose ID is the value + of that id attribute, + then let id be the value of that id attribute. +
    4. Set the attr content attribute to id. +
    +
+ +

If a reflecting IDL attribute has the type sequence<Element>, + or sequence<T> where T descends from Element...

+ +

TODO

+ +

Collections

From 6c993af319b9087ec3e55b6a9cd828923babec69 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Thu, 3 Jan 2019 14:31:46 +1100 Subject: [PATCH 02/20] Update element and sequence reflection sections --- source | 135 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 92 insertions(+), 43 deletions(-) diff --git a/source b/source index dd01601a878..53ae48c34f6 100644 --- a/source +++ b/source @@ -7219,59 +7219,108 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute whose associated attribute's local name is the name of the attribute in question.

If a reflecting IDL attribute has the type HTMLElement, - or an interface that descends from HTMLElement, - then it must be paired with another reflecting IDL attribute - that has the type DOMString. - The relationship between these two attributes is as follows:

+ or an interface that descends from HTMLElement, then: +
    +
  • On getting, it must run the following algorithm (stopping at the first point where a value is returned): +
      +
    1. If a value for the IDL attribute was previously set via the setting algorithm (below), + then return that value, regardless of the value of the content attribute. -
        -
      1. The attribute which has the type HTMLElement - should be named attrElement, - where the paired DOMString attribute is named - attr.
      2. +
      3. Otherwise, if the content attribute is absent, then return null.
      4. -
      5. On getting the attr attribute, - the IDL attribute must return the value of the content attribute as normal.
      6. +
      7. Otherwise, let id be the current value of the content attribute. -
      8. On getting the attrElement attribute, - it must run the following algorithm - (stopping at the first point where a value is returned):
      9. -
          -
        1. If the content attribute corresponding to attr - is absent, then the IDL attribute attrElement must return null.
        2. +
        3. Let candidate be the element that the + document.getElementById() method + would find when called on the content attribute's element's node document + if it were passed id as its argument.
        4. -
        5. Let candidate be the element that the - document.getElementById() method - would find when called on the content attribute's element's node document - if it were passed as its argument the current value - of the corresponding content attribute.
        6. +
        7. If candidate is null, or if it is not type-compatible with the IDL attribute, + then return null.
        8. -
        9. If candidate is null, or if it is not type-compatible with the IDL attribute, - then the IDL attribute must return null.
        10. +
        11. Otherwise, return candidate.
        12. +
        + +
      10. On setting, it must run the following algorithm: +
          +
        1. If the given value is null, remove the content attribute and stop.
        2. -
        3. Otherwise, it must return candidate.
        4. -
        -
      11. On setting the attr attribute, - the content attribute must be set to the specified value.
      12. +
      13. Otherwise, let id be the empty string.
      14. -
      15. On setting the attrElement attribute, - it must run the following algorithm:
      16. -
          -
        1. Let id be the empty string.
        2. -
        3. If the given element has an id attribute, - and has the same tree as the element of the attribute being set, - and the given element is the first element in that tree - whose ID is the value - of that id attribute, - then let id be the value of that id attribute. -
        4. Set the attr content attribute to id. -
        -
      +
    2. If the given element has an id attribute, + and has the same tree as the element of the attribute being set, + and the given element is the first element in that tree + whose ID is the value + of that id attribute, + then let id be the value of that id attribute.
    3. + +
    4. Set the content attribute to id.
    5. +
    +
  • +
  • If the content attribute is set directly (such as via Element.setAttribute()), + the value for the IDL attribute is re-set to the value produced by the getting algorithm, above.
  • +

If a reflecting IDL attribute has the type sequence<Element>, - or sequence<T> where T descends from Element...

+ or sequence<T> where T descends from Element, then: +
    +
  • On getting, it must run the following algorithm (stopping at the first point where a value is returned): +
      +
    1. If a value for the IDL attribute was previously set via the setting algorithm (below), + then it must return that value, regardless of the value of the content attribute. + +
    2. If the content attribute is absent, then the IDL attribute must return null.
    3. + +
    4. Otherwise, let elements be an empty list. -

      TODO

      +
    5. For each id in the set of space-separated tokens: +
        + +
      • Let candidate be the element that the + document.getElementById() method + would find when called on the content attribute's element's node document + if it were passed id as its argument.
      • + +
      • If candidate is null, or if it is not type-compatible with the IDL attribute, + then continue to the next token.
      • + +
      • Otherwise, append candidate to elements.
      • +
      + +
    6. Return elements. +
    +
  • +
  • On setting, it must run the following algorithm: +
      +
    1. If the given value is null, remove the content attribute and stop.
    2. + +
    3. Otherwise, let value be an empty string.
    4. + +
    5. For each element in the sequence: +
        +
      1. Let id be the empty string.
      2. + +
      3. If the given element has no id attribute, + or is not in the same tree as the element of the attribute being set, + or the given element is not the first element in that tree + whose ID is the value + of that id attribute, + then continue to the next element in the sequence. + +
      4. Otherwise, let id be the value of the element's id attribute. + +
      5. If value is non-empty, append a space character to value. + +
      6. Append id to value.
      7. +
      +
    6. + +
    7. Set the content attribute to value.
    8. +
    +
  • +
  • If the content attribute is set directly (such as via Element.setAttribute()), + the value for the IDL attribute is re-set to the value produced by the getting algorithm, above.
  • +
From 45e454ccb2cc424a36bbc990be5b0eb067ba2a61 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Mon, 7 Jan 2019 14:34:22 +1100 Subject: [PATCH 03/20] Address Anne's comments --- source | 170 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 108 insertions(+), 62 deletions(-) diff --git a/source b/source index 53ae48c34f6..b07bcd770e3 100644 --- a/source +++ b/source @@ -7218,108 +7218,154 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute return a DOMTokenList object whose associated element is the element in question and whose associated attribute's local name is the name of the attribute in question.

-

If a reflecting IDL attribute has the type HTMLElement, - or an interface that descends from HTMLElement, then: +

If a reflecting IDL attribute attr has the type Element, + or an interface that inherits from Element, then:

    -
  • On getting, it must run the following algorithm (stopping at the first point where a value is returned): +
  • This attribute defines an internal slot, [[attrAssociatedElement]], + on the attribute's element. The initial value for this slot is null.

  • + +
  • On getting, it must run the following algorithm + (stopping at the first point where a value is returned):

      -
    1. If a value for the IDL attribute was previously set via the setting algorithm (below), - then return that value, regardless of the value of the content attribute. +
    2. If the value of [[attrAssociatedElement]] is not null, + then return that value, regardless of the value of the content attribute.

    3. -
    4. Otherwise, if the content attribute is absent, then return null.
    5. +
    6. Otherwise, if the content attribute is absent, then return null.

    7. -
    8. Otherwise, let id be the current value of the content attribute. +
    9. Otherwise, let id be the current value of the content attribute.

    10. -
    11. Let candidate be the element that the - document.getElementById() method - would find when called on the content attribute's element's node document - if it were passed id as its argument.
    12. +
    13. Let candidate be the first element within + the content attribute's elements node document's + descendants whose ID is + id.

    14. -
    15. If candidate is null, or if it is not type-compatible with the IDL attribute, - then return null.
    16. +
    17. If candidate is null, or if it is not type-compatible with the IDL attribute, + then return null.

    18. -
    19. Otherwise, return candidate.
    20. +
    21. Otherwise, return candidate.

  • -
  • On setting, it must run the following algorithm: +
  • On setting, it must run the following algorithm:

      -
    1. If the given value is null, remove the content attribute and stop.
    2. +
    3. If the given value is null, or is not type-compatible with the IDL attribute, + or is not a descendant of either the attribute's element's root + or the attribute's element's shadow-including root:

      +
        +
      1. Set [[attrAssociatedElement]] to null.

      2. +
      3. Remove the content attribute.

      4. +
      5. Return.

      6. +
      +
    4. -
    5. Otherwise, let id be the empty string.
    6. +
    7. Otherwise, set [[attrAssociatedElement]] to the given value.

    8. -
    9. If the given element has an id attribute, - and has the same tree as the element of the attribute being set, - and the given element is the first element in that tree - whose ID is the value - of that id attribute, - then let id be the value of that id attribute.
    10. +
    11. Let id be the empty string.

    12. -
    13. Set the content attribute to id.
    14. +
    15. If the given element has an id attribute, + and is in a document tree with the same root + as the element of the attribute being set, + and the given element is the first element in that root's descendants + whose ID is the value + of that id attribute, + then let id be the value of that id attribute.

    16. + +
    17. Set the content attribute to id.

  • -
  • If the content attribute is set directly (such as via Element.setAttribute()), - the value for the IDL attribute is re-set to the value produced by the getting algorithm, above.
  • +
  • If the content attribute is set directly (such as via Element.setAttribute()), + the value for the IDL attribute is reset to null.

-

If a reflecting IDL attribute has the type sequence<Element>, - or sequence<T> where T descends from Element, then: +

If a reflecting IDL attribute attr has the type sequence<Element>, + or sequence<T> where T inherits from Element, then:

    -
  • On getting, it must run the following algorithm (stopping at the first point where a value is returned): +
  • This attribute defines an internal slot, [[attrAssociatedElements]], + on the attribute's element. The initial value for this slot is null.

  • + +
  • On getting, it must run the following algorithm (stopping at the first point where a value is returned):

      -
    1. If a value for the IDL attribute was previously set via the setting algorithm (below), - then it must return that value, regardless of the value of the content attribute. +
    2. If the value of [[attrAssociatedElements]] is not null, + then return that value, regardless of the value of the content attribute.

    3. -
    4. If the content attribute is absent, then the IDL attribute must return null.
    5. +
    6. If the content attribute is absent, then the IDL attribute must return null.

    7. -
    8. Otherwise, let elements be an empty list. +
    9. Otherwise, let elements be an empty list.

    10. -
    11. For each id in the set of space-separated tokens: +
    12. For each id in the set of space-separated tokens:

        +
      • Let candidate be the first element within + the content attribute's elements node document's + descendants whose ID is + id.

      • -
      • Let candidate be the element that the - document.getElementById() method - would find when called on the content attribute's element's node document - if it were passed id as its argument.
      • +
      • If candidate is null, + or if it is not type-compatible with the IDL attribute, + then continue to the next token.

      • -
      • If candidate is null, or if it is not type-compatible with the IDL attribute, - then continue to the next token.
      • - -
      • Otherwise, append candidate to elements.
      • +
      • Otherwise, append candidate to elements.

      - -
    13. Return elements. +
    14. +
    15. Return elements.

  • -
  • On setting, it must run the following algorithm: +
  • On setting, it must run the following algorithm:

      -
    1. If the given value is null, remove the content attribute and stop.
    2. +
    3. If the given value is null:

      +
        +
      1. Set [[attrAssociatedElements]] to null.

      2. +
      3. Remove the content attribute.

      4. +
      5. Return.

      6. +
      +
    4. -
    5. Otherwise, let value be an empty string.
    6. +
    7. Otherwise, let elements be an empty list, + and value be an empty string.

    8. -
    9. For each element in the sequence: +
    10. For each element in the sequence:

        -
      1. Let id be the empty string.
      2. - -
      3. If the given element has no id attribute, - or is not in the same tree as the element of the attribute being set, - or the given element is not the first element in that tree - whose ID is the value - of that id attribute, - then continue to the next element in the sequence. +
      4. If element is not type-compatible with the IDL attribute, + or is not a descendant of either the attribute's element's root + or the attribute's element's shadow-including root, + continue to the next element in the sequence.

      5. + +
      6. If value is empty and elements is non-empty:

        +
          +
        1. Append element to elements.

        2. +
        3. Continue to the next element in the sequence.

        4. +
        +
      7. + +
      8. Otherwise, append element to elements.

      9. + +
      10. If the given element has no id attribute, + or is not in a document tree with the same root + as the element of the attribute being set, + or the given element is not the first element in that tree + whose ID is the value + of that id attribute, then:

        +
          +
        1. Reset value to be the empty string.

        2. +
        3. Continue to the next element in the sequence.

        4. +
        +
      11. -
      12. Otherwise, let id be the value of the element's id attribute. +
      13. Otherwise, let id be the value of + the element's id attribute.

      14. -
      15. If value is non-empty, append a space character to value. +
      16. If value is non-empty, append a space character to value.

      17. -
      18. Append id to value.
      19. +
      20. Append id to value.

    11. -
    12. Set the content attribute to value.
    13. +
    14. Set [[attrAssociatedElements]] to elements.

    15. + +
    16. Set the content attribute to value.

  • -
  • If the content attribute is set directly (such as via Element.setAttribute()), - the value for the IDL attribute is re-set to the value produced by the getting algorithm, above.
  • + +
  • If the content attribute is set directly (such as via Element.setAttribute()), + the value for the IDL attribute is reset to null.

From fcdff874fa2af4f406ba9cc8df77828064799c90 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Mon, 7 Jan 2019 15:09:59 -0500 Subject: [PATCH 04/20] Source formatting nits --- source | 238 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 121 insertions(+), 117 deletions(-) diff --git a/source b/source index b07bcd770e3..1a62165acff 100644 --- a/source +++ b/source @@ -7221,151 +7221,155 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

If a reflecting IDL attribute attr has the type Element, or an interface that inherits from Element, then:

    -
  • This attribute defines an internal slot, [[attrAssociatedElement]], - on the attribute's element. The initial value for this slot is null.

  • +
  • This attribute defines an internal slot, [[attrAssociatedElement]], on the + attribute's element. The initial value for this slot is null.

  • -
  • On getting, it must run the following algorithm - (stopping at the first point where a value is returned):

    -
      -
    1. If the value of [[attrAssociatedElement]] is not null, - then return that value, regardless of the value of the content attribute.

    2. +
    3. +

      On getting, it must run the following algorithm:

      +
        +
      1. If the value of [[attrAssociatedElement]] is not null, then return that + value, regardless of the value of the content attribute.

      2. -
      3. Otherwise, if the content attribute is absent, then return null.

      4. +
      5. Otherwise, if the content attribute is absent, then return null.

      6. -
      7. Otherwise, let id be the current value of the content attribute.

      8. +
      9. Otherwise, let id be the current value of the content attribute.

      10. -
      11. Let candidate be the first element within - the content attribute's elements node document's - descendants whose ID is - id.

      12. +
      13. Let candidate be the first element within the content attribute's element's + node document's descendants whose ID is + id.

      14. -
      15. If candidate is null, or if it is not type-compatible with the IDL attribute, - then return null.

      16. +
      17. If candidate is null, or if it is not type-compatible with the IDL attribute, + then return null.

      18. -
      19. Otherwise, return candidate.

      20. -
      -
    4. -
    5. On setting, it must run the following algorithm:

      +
    6. Otherwise, return candidate.

    7. +
    +
  • +
  • +

    On setting, it must run the following algorithm:

    +
      +
    1. +

      If the given value is null, or is not type-compatible with the IDL attribute, or is not a + descendant of either the attribute's element's root or the attribute's element's + shadow-including root:

        -
      1. If the given value is null, or is not type-compatible with the IDL attribute, - or is not a descendant of either the attribute's element's root - or the attribute's element's shadow-including root:

        -
          -
        1. Set [[attrAssociatedElement]] to null.

        2. -
        3. Remove the content attribute.

        4. -
        5. Return.

        6. -
        -
      2. +
      3. Set [[attrAssociatedElement]] to null.

      4. Remove the content + attribute.

      5. Return.

      6. +
      +
    2. + +
    3. Otherwise, set [[attrAssociatedElement]] to the given value.

    4. -
    5. Otherwise, set [[attrAssociatedElement]] to the given value.

    6. +
    7. Let id be the empty string.

    8. -
    9. Let id be the empty string.

    10. +
    11. If the given element has an id attribute, and is in + a document tree with the same root as the element of the attribute being + set, and the given element is the first element in that root's descendants whose + ID is the value of that id + attribute, then let id be the value of that id + attribute.

    12. -
    13. If the given element has an id attribute, - and is in a document tree with the same root - as the element of the attribute being set, - and the given element is the first element in that root's descendants - whose ID is the value - of that id attribute, - then let id be the value of that id attribute.

    14. +
    15. Set the content attribute to id.

    16. +
    +
  • -
  • Set the content attribute to id.

  • - - -
  • If the content attribute is set directly (such as via Element.setAttribute()), - the value for the IDL attribute is reset to null.

  • +
  • If the content attribute is set directly (such as via Element.setAttribute()), the value for the IDL attribute is reset to null.

-

If a reflecting IDL attribute attr has the type sequence<Element>, - or sequence<T> where T inherits from Element, then: +

If a reflecting IDL attribute attr has the type sequence<Element>, or sequence<T> where + T inherits from Element, then:

+
    -
  • This attribute defines an internal slot, [[attrAssociatedElements]], - on the attribute's element. The initial value for this slot is null.

  • +
  • This attribute defines an internal slot, [[attrAssociatedElements]], on the + attribute's element. The initial value for this slot is null.

  • -
  • On getting, it must run the following algorithm (stopping at the first point where a value is returned):

    -
      -
    1. If the value of [[attrAssociatedElements]] is not null, - then return that value, regardless of the value of the content attribute.

    2. +
    3. +

      On getting, it must run the following algorithm:

      +
        +
      1. If the value of [[attrAssociatedElements]] is not null, then return that + value, regardless of the value of the content attribute.

      2. -
      3. If the content attribute is absent, then the IDL attribute must return null.

      4. +
      5. If the content attribute is absent, then the IDL attribute must return null.

      6. -
      7. Otherwise, let elements be an empty list.

      8. +
      9. Otherwise, let elements be an empty list.

      10. -
      11. For each id in the set of space-separated tokens:

        -
          -
        • Let candidate be the first element within - the content attribute's elements node document's - descendants whose ID is - id.

        • +
        • +

          For each id in the set of space-separated tokens:

          +
            +
          • Let candidate be the first element within the content attribute's elements + node document's descendants whose ID is + id.

          • -
          • If candidate is null, - or if it is not type-compatible with the IDL attribute, - then continue to the next token.

          • +
          • If candidate is null, or if it is not type-compatible with the IDL + attribute, then continue to the next token.

          • -
          • Otherwise, append candidate to elements.

          • -
          -
        • -
        • Return elements.

        • +
        • Otherwise, append candidate to elements.

        • +
        +
      12. +
      13. Return elements.

      14. +
      +
    4. +
    5. +

      On setting, it must run the following algorithm:

      +
        +
      1. +

        If the given value is null:

        +
          +
        1. Set [[attrAssociatedElements]] to null.

        2. Remove the content + attribute.

        3. Return.

        -
      2. -
      3. On setting, it must run the following algorithm:

        +
      4. + +
      5. Otherwise, let elements be an empty list, and value be an empty + string.

      6. + +
      7. +

        For each element in the sequence:

          -
        1. If the given value is null:

          -
            -
          1. Set [[attrAssociatedElements]] to null.

          2. -
          3. Remove the content attribute.

          4. -
          5. Return.

          6. -
          -
        2. +
        3. If element is not type-compatible with the IDL attribute, or is not a + descendant of either the attribute's element's root or the attribute's element's + shadow-including root, continue to the next element in the sequence.

        4. + +
        5. +

          If value is empty and elements is non-empty:

          +
            +
          1. Append element to elements.

          2. Continue to the + next element in the sequence.

          3. +
          +
        6. -
        7. Otherwise, let elements be an empty list, - and value be an empty string.

        8. +
        9. Otherwise, append element to elements.

        10. -
        11. For each element in the sequence:

          -
            -
          1. If element is not type-compatible with the IDL attribute, - or is not a descendant of either the attribute's element's root - or the attribute's element's shadow-including root, - continue to the next element in the sequence.

          2. - -
          3. If value is empty and elements is non-empty:

            -
              -
            1. Append element to elements.

            2. -
            3. Continue to the next element in the sequence.

            4. -
            -
          4. - -
          5. Otherwise, append element to elements.

          6. - -
          7. If the given element has no id attribute, - or is not in a document tree with the same root - as the element of the attribute being set, - or the given element is not the first element in that tree - whose ID is the value - of that id attribute, then:

            -
              -
            1. Reset value to be the empty string.

            2. -
            3. Continue to the next element in the sequence.

            4. -
            -
          8. - -
          9. Otherwise, let id be the value of - the element's id attribute.

          10. - -
          11. If value is non-empty, append a space character to value.

          12. - -
          13. Append id to value.

          14. -
          -
        12. +
        13. +

          If the given element has no id attribute, or is not + in a document tree with the same root as the element of the + attribute being set, or the given element is not the first element in that tree + whose ID is the value of that id attribute, then:

          +
            +
          1. Reset value to be the empty string.

          2. Continue to the next + element in the sequence.

          3. +
          +
        14. -
        15. Set [[attrAssociatedElements]] to elements.

        16. +
        17. Otherwise, let id be the value of the element's id attribute.

        18. -
        19. Set the content attribute to value.

        20. +
        21. If value is non-empty, append a space character to value.

        22. + +
        23. Append id to value.

        -
      8. + + +
      9. Set [[attrAssociatedElements]] to elements.

      10. + +
      11. Set the content attribute to value.

      12. +
      +
    6. -
    7. If the content attribute is set directly (such as via Element.setAttribute()), - the value for the IDL attribute is reset to null.

    8. +
    9. If the content attribute is set directly (such as via Element.setAttribute()), the value for the IDL attribute is reset to null.

From d58b34a0d276b40cd808759b98a6e9efbf252124 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Mon, 7 Jan 2019 15:22:27 -0500 Subject: [PATCH 05/20] More tweaks --- source | 54 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/source b/source index 1a62165acff..389b7d51f10 100644 --- a/source +++ b/source @@ -7225,7 +7225,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute attribute's element. The initial value for this slot is null.

  • -

    On getting, it must run the following algorithm:

    +

    On getting:

    1. If the value of [[attrAssociatedElement]] is not null, then return that value, regardless of the value of the content attribute.

    2. @@ -7244,16 +7244,18 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
    3. Otherwise, return candidate.

  • +
  • -

    On setting, it must run the following algorithm:

    +

    On setting:

    1. If the given value is null, or is not type-compatible with the IDL attribute, or is not a descendant of either the attribute's element's root or the attribute's element's shadow-including root:

        -
      1. Set [[attrAssociatedElement]] to null.

      2. Remove the content - attribute.

      3. Return.

      4. +
      5. Set [[attrAssociatedElement]] to null.

      6. +
      7. Remove the content attribute.

      8. +
      9. Return.

    2. @@ -7268,7 +7270,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute attribute, then let id be the value of that id attribute.

      -
    3. Set the content attribute to id.

    4. +
    5. Set the content attribute's value to id.

  • @@ -7285,39 +7287,44 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute attribute's element. The initial value for this slot is null.

  • -

    On getting, it must run the following algorithm:

    +

    On getting:

    1. If the value of [[attrAssociatedElements]] is not null, then return that value, regardless of the value of the content attribute.

    2. -
    3. If the content attribute is absent, then the IDL attribute must return null.

    4. +
    5. If the content attribute is absent, then return null.

    6. Otherwise, let elements be an empty list.

    7. -

      For each id in the set of space-separated tokens:

      +

      For each id in the set of space-separated + tokens:

      +
      • Let candidate be the first element within the content attribute's elements node document's descendants whose ID is id.

      • If candidate is null, or if it is not type-compatible with the IDL - attribute, then continue to the next token.

      • + attribute, then continue.

      • Otherwise, append candidate to elements.

    8. +
    9. Return elements.

  • +
  • -

    On setting, it must run the following algorithm:

    +

    On setting:

    1. If the given value is null:

        -
      1. Set [[attrAssociatedElements]] to null.

      2. Remove the content - attribute.

      3. Return.

      4. +
      5. Set [[attrAssociatedElements]] to null.

      6. +
      7. Remove the content attribute.

      8. +
      9. Return.

    2. @@ -7325,21 +7332,22 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute string.

    3. -

      For each element in the sequence:

      +

      For each element in the given value:

        -
      1. If element is not type-compatible with the IDL attribute, or is not a - descendant of either the attribute's element's root or the attribute's element's - shadow-including root, continue to the next element in the sequence.

      2. +
      3. If element is not type-compatible with the IDL attribute's inner type, or + is not a descendant of either the attribute's element's root or the attribute's + element's shadow-including root, then continue.

      4. If value is empty and elements is non-empty:

          -
        1. Append element to elements.

        2. Continue to the - next element in the sequence.

        3. +
        4. Append element to elements.

        5. +
        6. Continue.

      5. -
      6. Otherwise, append element to elements.

      7. +
      8. Otherwise, append element to + elements.

      9. If the given element has no id attribute, or is not @@ -7348,15 +7356,15 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute whose ID is the value of that id attribute, then:

          -
        1. Reset value to be the empty string.

        2. Continue to the next - element in the sequence.

        3. +
        4. Reset value to be the empty string.

        5. +
        6. Continue.

      10. Otherwise, let id be the value of the element's id attribute.

      11. -
      12. If value is non-empty, append a space character to value.

      13. +
      14. If value is non-empty, append U+0020 SPACE to value.

      15. Append id to value.

      @@ -7364,7 +7372,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
    4. Set [[attrAssociatedElements]] to elements.

    5. -
    6. Set the content attribute to value.

    7. +
    8. Set the content attribute's value to value.

  • From d405676150286fe18bbaa4e279b0cf1bd4f1f73a Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Tue, 8 Jan 2019 09:16:41 +1100 Subject: [PATCH 06/20] Nullable types and attribute change steps --- source | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/source b/source index 389b7d51f10..49674280fdd 100644 --- a/source +++ b/source @@ -7218,8 +7218,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute return a DOMTokenList object whose associated element is the element in question and whose associated attribute's local name is the name of the attribute in question.

    -

    If a reflecting IDL attribute attr has the type Element, - or an interface that inherits from Element, then: +

    If a reflecting IDL attribute attr has the type Element?, or an interface that inherits from Element?, then:

    • This attribute defines an internal slot, [[attrAssociatedElement]], on the attribute's element. The initial value for this slot is null.

    • @@ -7274,13 +7275,20 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute -
    • If the content attribute is set directly (such as via Element.setAttribute()), the value for the IDL attribute is reset to null.

    • +
    • +

      The following attribute change + step is used to synchronize between the content attribute and the IDL attribute:

      +
        +
      1. If localName is associated attribute’s local name, and namespace + is null, reset [[attrAssociatedElement]] to null.

      2. +
      +

    If a reflecting IDL attribute attr has the type sequence<Element>, or sequence<T> where - T inherits from Element, then:

    + data-x="">sequence<Element>?, or sequence<T>? where T inherits from + Element, then:

    • This attribute defines an internal slot, [[attrAssociatedElements]], on the @@ -7296,10 +7304,11 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    • Otherwise, let elements be an empty list.

    • -
    • -

      For each id in the set of space-separated - tokens:

      +
    • Let tokens be the content attribute's value, split on ASCII whitespace.

    • +
    • +

      For each id in tokens:

      • Let candidate be the first element within the content attribute's elements node document's descendants whose ID is @@ -7376,8 +7385,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

      • -
      • If the content attribute is set directly (such as via Element.setAttribute()), the value for the IDL attribute is reset to null.

      • +
      • +

        The following attribute change + step is used to synchronize between the content attribute and the IDL attribute:

        +
          +
        1. If localName is associated attribute’s local name, and namespace + is null, reset [[attrAssociatedElements]] to null.

        2. +
        +
      From ec4438c5d8123cdaea5aeada493a88360fbf1023 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Thu, 10 Jan 2019 15:18:05 +1100 Subject: [PATCH 07/20] Use FrozenArray; move IDREF parsing step to attribute update steps --- source | 163 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 81 insertions(+), 82 deletions(-) diff --git a/source b/source index 49674280fdd..16ec26f572d 100644 --- a/source +++ b/source @@ -2937,6 +2937,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
    • The tree, shadow tree, and node tree concepts
    • The tree order and shadow-including tree order concepts
    • +
    • The node tree concept
    • The child concept
    • The root and shadow-including root concepts
    • The inclusive ancestor, @@ -7225,26 +7226,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
    • This attribute defines an internal slot, [[attrAssociatedElement]], on the attribute's element. The initial value for this slot is null.

    • -
    • -

      On getting:

      -
        -
      1. If the value of [[attrAssociatedElement]] is not null, then return that - value, regardless of the value of the content attribute.

      2. - -
      3. Otherwise, if the content attribute is absent, then return null.

      4. - -
      5. Otherwise, let id be the current value of the content attribute.

      6. - -
      7. Let candidate be the first element within the content attribute's element's - node document's descendants whose ID is - id.

      8. - -
      9. If candidate is null, or if it is not type-compatible with the IDL attribute, - then return null.

      10. - -
      11. Otherwise, return candidate.

      12. -
      -
    • +
    • On getting, return the value of [[attrAssociatedElement]].

    • On setting:

      @@ -7264,12 +7246,15 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
    • Let id be the empty string.

    • -
    • If the given element has an id attribute, and is in - a document tree with the same root as the element of the attribute being - set, and the given element is the first element in that root's descendants whose - ID is the value of that id - attribute, then let id be the value of that id - attribute.

    • +
    • If the given element:

      +
        +
      • has an id attribute, and

      • +
      • has the same root as the element of the attribute being set, and

      • +
      • is the first element in the element's node tree whose ID is the value of that id + attribute,

      • +
      +

      then let id be the element's ID.

    • Set the content attribute's value to id.

    • @@ -7277,53 +7262,41 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
    • The following attribute change - step is used to synchronize between the content attribute and the IDL attribute:

      + steps are used to synchronize between the content attribute and the IDL attribute:

        -
      1. If localName is associated attribute’s local name, and namespace - is null, reset [[attrAssociatedElement]] to null.

      2. +
      3. If localName is not associated attribute’s local name, or + namespace is not null, return.

      4. + +
      5. +

        If value is null, then:

        +
          +
        1. Reset [[attrAssociatedElements]] to null.

        2. +
        3. Return.

        4. +
        +
      6. + +
      7. Let candidate be the first element, in tree order, within the content + attribute's element's node tree whose ID is + value.

      8. + +
      9. If candidate is null, or if it is not type-compatible with the IDL attribute, + then set [[attrAssociatedElement]] to null.

      10. + +
      11. Otherwise, set [[attrAssociatedElement]] to candidate.

    If a reflecting IDL attribute attr has the type sequence<Element>?, or sequence<T>? where T inherits from + data-x="">FrozenArray<Element>?, or FrozenArray<T>? where T inherits from Element, then:

    • This attribute defines an internal slot, [[attrAssociatedElements]], on the attribute's element. The initial value for this slot is null.

    • -
    • -

      On getting:

      -
        -
      1. If the value of [[attrAssociatedElements]] is not null, then return that - value, regardless of the value of the content attribute.

      2. - -
      3. If the content attribute is absent, then return null.

      4. - -
      5. Otherwise, let elements be an empty list.

      6. - -
      7. Let tokens be the content attribute's value, split on ASCII whitespace.

      8. - -
      9. -

        For each id in tokens:

        -
          -
        • Let candidate be the first element within the content attribute's elements - node document's descendants whose ID is - id.

        • - -
        • If candidate is null, or if it is not type-compatible with the IDL - attribute, then continue.

        • - -
        • Otherwise, append candidate to elements.

        • -
        -
      10. - -
      11. Return elements.

      12. -
      -
    • +
    • On getting, return the value of [[attrAssociatedElements]].

    • On setting:

      @@ -7347,31 +7320,28 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute is not a descendant of either the attribute's element's root or the attribute's element's shadow-including root, then continue.

    • -
    • -

      If value is empty and elements is non-empty:

      -
        -
      1. Append element to elements.

      2. -
      3. Continue.

      4. -
      -
    • +
    • If value is empty and elements is non-empty, append element to elements and + continue.

    • Otherwise, append element to elements.

    • -

      If the given element has no id attribute, or is not - in a document tree with the same root as the element of the - attribute being set, or the given element is not the first element in that tree - whose ID is the value of that id attribute, then:

      -
        -
      1. Reset value to be the empty string.

      2. -
      3. Continue.

      4. -
      +

      If the given element:

      +
        +
      • has no id attribute, or

      • +
      • does not have the same root as the element of the attribute being set, + or

      • +
      • is not the first element in the element's node tree whose ID is the value of that id + attribute,

      • +
      +

      then reset value to be the empty string, and continue.

    • -
    • Otherwise, let id be the value of the element's id attribute.

    • +
    • Otherwise, let id be the element's ID.

    • If value is non-empty, append U+0020 SPACE to value.

    • @@ -7387,10 +7357,39 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
    • The following attribute change - step is used to synchronize between the content attribute and the IDL attribute:

      + steps are used to synchronize between the content attribute and the IDL attribute:

        -
      1. If localName is associated attribute’s local name, and namespace - is null, reset [[attrAssociatedElements]] to null.

      2. +
      3. If localName is not associated attribute’s local name, or + namespace is not null, return.

      4. + +
      5. +

        If value is null, then:

        +
          +
        1. Reset [[attrAssociatedElements]] to null.

        2. +
        3. Return.

        4. +
        +
      6. + +
      7. Let elements be an empty list.

      8. + +
      9. Let tokens be the content attribute's value, split on ASCII whitespace.

      10. + +
      11. +

        For each id in tokens:

        +
          +
        • Let candidate be the first element, in tree order, within the content + attribute's elements node tree whose ID is + id.

        • + +
        • If candidate is null, or if it is not type-compatible with the IDL + attribute, then continue.

        • + +
        • Otherwise, append candidate to elements.

        • +
        +
      12. + +
      13. Set [[attrAssociatedElements]] to elements.

    From d5859bd95c0107d5a1bd359268df75504716f687 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Tue, 15 Jan 2019 09:41:09 +1100 Subject: [PATCH 08/20] Review comments from Anne --- source | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source b/source index 16ec26f572d..5000373b1dc 100644 --- a/source +++ b/source @@ -7220,8 +7220,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute whose associated attribute's local name is the name of the attribute in question.

    If a reflecting IDL attribute attr has the type Element?, or an interface that inherits from Element?, then: + data-x="">Element?, or type T? where T is an interface + that inherits from Element, then:

    • This attribute defines an internal slot, [[attrAssociatedElement]], on the attribute's element. The initial value for this slot is null.

    • @@ -7233,8 +7233,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
      1. If the given value is null, or is not type-compatible with the IDL attribute, or is not a - descendant of either the attribute's element's root or the attribute's element's - shadow-including root:

        + descendant of either the attribute's element's root or, if the element's + root is a shadow root, the attribute's element's host's root:
        1. Set [[attrAssociatedElement]] to null.

        2. Remove the content attribute.

        3. @@ -7254,7 +7255,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute data-x="concept-ID">ID is the value of that id attribute,

    -

    then let id be the element's ID. +

    then set id to the element's ID.

  • Set the content attribute's value to id.

  • @@ -7270,7 +7271,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • If value is null, then:

      -
    1. Reset [[attrAssociatedElements]] to null.

    2. +
    3. Set [[attrAssociatedElements]] to null.

    4. Return.

  • @@ -7337,13 +7338,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute data-x="concept-ID">ID is the value of that id attribute,

    -

    then reset value to be the empty string, and continue.

    +

    then set value to be the empty string, and continue.

  • Otherwise, let id be the element's ID.

  • -
  • If value is non-empty, append U+0020 SPACE to value.

  • +
  • If value is not the empty string, append U+0020 SPACE to + value.

  • Append id to value.

  • From d3ba958222e669e4b9bc9504272e4f10273d4f3f Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Tue, 15 Jan 2019 13:51:33 +1100 Subject: [PATCH 09/20] Allow elements to be from any less-nested shadow tree --- source | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/source b/source index 5000373b1dc..151d0b03e5a 100644 --- a/source +++ b/source @@ -2937,10 +2937,11 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The tree, shadow tree, and node tree concepts
  • The tree order and shadow-including tree order concepts
  • -
  • The node tree concept
  • The child concept
  • The root and shadow-including root concepts
  • The inclusive ancestor, + descendant, + shadow-including ancestor, shadow-including descendant, shadow-including inclusive descendant, and shadow-including inclusive ancestor concepts
  • @@ -7232,10 +7233,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    On setting:

    1. -

      If the given value is null, or is not type-compatible with the IDL attribute, or is not a - descendant of either the attribute's element's root or, if the element's - root is a shadow root, the attribute's element's host's root: +

      If the given value is:

      +
        +
      • null, or

      • +
      • not type-compatible with the IDL attribute, or

      • +
      • not a descendant of any of the attribute's element's shadow-including ancestors,

      • +
      +

      then:

      1. Set [[attrAssociatedElement]] to null.

      2. Remove the content attribute.

      3. From 7350c168ec9443d09097bc24f69a489b2f28d238 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Wed, 16 Jan 2019 08:14:27 +1100 Subject: [PATCH 10/20] Do not run attribute change steps if attribute was set via reflection --- source | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source b/source index 151d0b03e5a..c2db0aadcd7 100644 --- a/source +++ b/source @@ -7273,6 +7273,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
      4. If localName is not associated attribute’s local name, or namespace is not null, return.

      5. +
      6. If the content attribute was set via reflection of the IDL attribute, return.

      7. +
      8. If value is null, then:

          @@ -7369,6 +7371,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
        1. If localName is not associated attribute’s local name, or namespace is not null, return.

        2. +
        3. If the content attribute was set via reflection of the IDL attribute, return.

        4. +
        5. If value is null, then:

            From 6487b47781799af8b30aefa03b7e169c40f6fbc7 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Thu, 17 Jan 2019 08:47:38 +1100 Subject: [PATCH 11/20] Be more explicit about checking whether the content attribute was set via reflection --- source | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/source b/source index c2db0aadcd7..b8a5c87ff60 100644 --- a/source +++ b/source @@ -7224,14 +7224,20 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute data-x="">Element?, or type T? where T is an interface that inherits from Element, then:
              -
            • This attribute defines an internal slot, [[attrAssociatedElement]], on the - attribute's element. The initial value for this slot is null.

            • +
            • +

              This attribute defines two internal slots on the attribute's element:

              +
                +
              • [[attrAssociatedElement]], with an initial value of null;

              • +
              • [[attrSetViaReflection]], with an initial value of false.

              • +
              +
            • On getting, return the value of [[attrAssociatedElement]].

            • On setting:

                +
              1. Set [[attrSetViaReflection]] to true.

              2. If the given value is:

                  @@ -7273,7 +7279,15 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
                • If localName is not associated attribute’s local name, or namespace is not null, return.

                • -
                • If the content attribute was set via reflection of the IDL attribute, return.

                • +
                • +

                  If [[attrSetViaReflection]] is true:

                  +
                    +
                  1. Set [[attrSetViaReflection]] to false.

                  2. +
                  3. Return.

                  4. +
                  +
                • + +
                • Set [[attrSetViaReflection]] to false.

                • If value is null, then:

                  @@ -7301,14 +7315,20 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute Element, then:

                    -
                  • This attribute defines an internal slot, [[attrAssociatedElements]], on the - attribute's element. The initial value for this slot is null.

                  • +
                  • +

                    This attribute defines two internal slots on the attribute's element:

                    +
                      +
                    • [[attrAssociatedElements]], with an initial value of null;

                    • +
                    • [[attrSetViaReflection]], with an initial value of false.

                    • +
                    +
                  • On getting, return the value of [[attrAssociatedElements]].

                  • On setting:

                      +
                    1. Set [[attrSetViaReflection]] to true.

                    2. If the given value is null:

                        @@ -7318,7 +7338,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
                    3. -
                    4. Otherwise, let elements be an empty list, and value be an empty +

                    5. Set [[attrSetViaReflection]] to false.

                    6. + +
                    7. Let elements be an empty list, and value be an empty string.

                    8. @@ -7371,7 +7393,13 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
                    9. If localName is not associated attribute’s local name, or namespace is not null, return.

                    10. -
                    11. If the content attribute was set via reflection of the IDL attribute, return.

                    12. +
                    13. +

                      If [[attrSetViaReflection]] is true:

                      +
                        +
                      1. Set [[attrSetViaReflection]] to false.

                      2. +
                      3. Return.

                      4. +
                      +
                    14. If value is null, then:

                      From 8e27621e3b96be11cb111523827bc27f3f8fc362 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Wed, 3 Jul 2019 14:13:11 +1000 Subject: [PATCH 12/20] Fix typo attrAssociatedElements -> attrAssociatedElement --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index b8a5c87ff60..a2200b9be01 100644 --- a/source +++ b/source @@ -7292,7 +7292,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
                    15. If value is null, then:

                        -
                      1. Set [[attrAssociatedElements]] to null.

                      2. +
                      3. Set [[attrAssociatedElement]] to null.

                      4. Return.

                    16. From bda010291540bb956e5b7d6b5151e337c7c0df80 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Thu, 4 Jul 2019 15:13:03 +1000 Subject: [PATCH 13/20] Rework definition of attr-associated element(s) to avoid over-specifying --- source | 151 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 73 insertions(+), 78 deletions(-) diff --git a/source b/source index a2200b9be01..238e9403b35 100644 --- a/source +++ b/source @@ -7224,25 +7224,43 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute data-x="">Element?, or type T? where T is an interface that inherits from Element, then:
                        +
                      • The attribute's element can be associated with a particular other element, referred to as + its attr-associated element.

                      • + +
                      • Except where otherwise specified by the following rules, an element has no + attr-associated element.

                      • + +
                      • This attribute defines an internal slot on element named + [[attrAssociatedElement]], with an initial value of null;

                      • + +
                      • If the value of [[attrAssociatedElement]] is not null, the element's + attr-associated element is the value of + [[attrAssociatedElement]].

                      • +
                      • -

                        This attribute defines two internal slots on the attribute's element:

                        +

                        If the value of [[attrAssociatedElement]] is null, and the value of the content + attribute is not null, then the element's attr-associated element is the + first element, in tree order, within the content attribute's element's node tree + which meets the following criteria:

                          -
                        • [[attrAssociatedElement]], with an initial value of null;

                        • -
                        • [[attrSetViaReflection]], with an initial value of false.

                        • +
                        • the element's ID is the value of the content + attribute, and

                        • +
                        • the element is type-compatible with the IDL attribute.

                        +

                        If no element exists which meeds both criteria, then the element has no + attr-associated element.

                      • -
                      • On getting, return the value of [[attrAssociatedElement]].

                      • +
                      • On getting, the IDL attribute must return the element's attr-associated + element.

                      • On setting:

                          -
                        1. Set [[attrSetViaReflection]] to true.

                        2. If the given value is:

                          • null, or

                          • -
                          • not type-compatible with the IDL attribute, or

                          • not a descendant of any of the attribute's element's shadow-including ancestors,

                          @@ -7268,7 +7286,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

                      then set id to the element's ID. -

                    17. Set the content attribute's value to id.

                    18. +
                    19. Set the content attribute's value to id, skipping the attribute change steps.

                  • @@ -7279,32 +7298,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
                  • If localName is not associated attribute’s local name, or namespace is not null, return.

                  • -
                  • -

                    If [[attrSetViaReflection]] is true:

                    -
                      -
                    1. Set [[attrSetViaReflection]] to false.

                    2. -
                    3. Return.

                    4. -
                    -
                  • - -
                  • Set [[attrSetViaReflection]] to false.

                  • - -
                  • -

                    If value is null, then:

                    -
                      -
                    1. Set [[attrAssociatedElement]] to null.

                    2. -
                    3. Return.

                    4. -
                    -
                  • - -
                  • Let candidate be the first element, in tree order, within the content - attribute's element's node tree whose ID is - value.

                  • - -
                  • If candidate is null, or if it is not type-compatible with the IDL attribute, - then set [[attrAssociatedElement]] to null.

                  • - -
                  • Otherwise, set [[attrAssociatedElement]] to candidate.

                  • +
                  • Set [[attrAssociatedElement]] to null.

            @@ -7314,21 +7308,58 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute data-x="">FrozenArray<T>? where T inherits from Element, then:

            -
              +
                +
              • The attribute's element can be associated with a list of other elements, referred to as + its attr-associated elements.

              • + +
              • Except where otherwise specified by the following rules, an element has no + attr-associated elements.

              • + +
              • This attribute defines an internal slot on element named + [[attrAssociatedElements]], with an initial value of null.

              • + +
              • If the value of [[attrAssociatedElements]] is not null, the element's + attr-associated elements list is the value of + [[attrAssociatedElements]].

              • +
              • -

                This attribute defines two internal slots on the attribute's element:

                +

                If the value of [[attrAssociatedElements]] is null, and the value of the content + attribute is not null, then the element's attr-associated element is + computed as follows:

                  -
                • [[attrAssociatedElements]], with an initial value of null;

                • -
                • [[attrSetViaReflection]], with an initial value of false.

                • +
                • Let elements be an empty list.

                • + +
                • Let tokens be the content attribute's value, split on ASCII whitespace.

                • + +
                • +

                  For each id in tokens:

                  +
                    +
                  • Let candidate be the first element, in tree order, within the content + attribute's elements node tree whose ID is + id.

                  • + +
                  • If candidate is null, or if it is not type-compatible with the IDL + attribute, then continue.

                  • + +
                  • Otherwise, append candidate to elements.

                  • +
                  +
                • + +
                • If elements is empty, then the element has no + attr-associated elements.

                • + +
                • Otherwise, the element's attr-associated elements is + elements.

              • -
              • On getting, return the value of [[attrAssociatedElements]].

              • +
              • On getting, the IDL attribute must return the element's attr-associated + element, or null if it does not exist.

              • On setting:

                  -
                1. Set [[attrSetViaReflection]] to true.

                2. If the given value is null:

                    @@ -7338,8 +7369,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
                3. -
                4. Set [[attrSetViaReflection]] to false.

                5. -
                6. Let elements be an empty list, and value be an empty string.

                7. @@ -7382,7 +7411,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
                8. Set [[attrAssociatedElements]] to elements.

                9. -
                10. Set the content attribute's value to value.

                11. +
                12. Set the content attribute's value to value, skipping the attribute change steps.

              • @@ -7393,42 +7423,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
              • If localName is not associated attribute’s local name, or namespace is not null, return.

              • -
              • -

                If [[attrSetViaReflection]] is true:

                -
                  -
                1. Set [[attrSetViaReflection]] to false.

                2. -
                3. Return.

                4. -
                -
              • - -
              • -

                If value is null, then:

                -
                  -
                1. Reset [[attrAssociatedElements]] to null.

                2. -
                3. Return.

                4. -
                -
              • - -
              • Let elements be an empty list.

              • - -
              • Let tokens be the content attribute's value, split on ASCII whitespace.

              • - -
              • -

                For each id in tokens:

                -
                  -
                • Let candidate be the first element, in tree order, within the content - attribute's elements node tree whose ID is - id.

                • - -
                • If candidate is null, or if it is not type-compatible with the IDL - attribute, then continue.

                • - -
                • Otherwise, append candidate to elements.

                • -
                -
              • - -
              • Set [[attrAssociatedElements]] to elements.

              • +
              • Set [[attrAssociatedElements]] to null.

        6. From f6e501f063bd2766c57bb5237e33f273f95cb935 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Fri, 2 Aug 2019 14:52:03 +1000 Subject: [PATCH 14/20] Address domenic's comments --- source | 94 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/source b/source index 238e9403b35..d68d54f5ffe 100644 --- a/source +++ b/source @@ -7224,31 +7224,35 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute data-x="">Element?, or type T? where T is an interface that inherits from Element, then:
            -
          • The attribute's element can be associated with a particular other element, referred to as - its attr-associated element.

          • +
          • This attribute defines an internal slot on element named + [[attrElement]], with an initial value of null;

          • -
          • Except where otherwise specified by the following rules, an element has no - attr-associated element.

          • +
          • +

            The attribute's element can be associated with a particular other element, referred to as its + attr-associated element. To compute the attr-associated + element for a particular element:

            -
          • This attribute defines an internal slot on element named - [[attrAssociatedElement]], with an initial value of null;

          • +
              +
            1. If the value of [[attrElement]] is not null, then return the value of + [[attrElement]].

            2. -
            3. If the value of [[attrAssociatedElement]] is not null, the element's - attr-associated element is the value of - [[attrAssociatedElement]].

            4. +
            5. +

              Otherwise, if the value of [[attrElement]] is null, and the value of the content + attribute is not null, let candidate be the first element, in tree order, within + the content attribute's element's node tree which meets the following + criteria:

              -
            6. -

              If the value of [[attrAssociatedElement]] is null, and the value of the content - attribute is not null, then the element's attr-associated element is the - first element, in tree order, within the content attribute's element's node tree - which meets the following criteria:

              -
                -
              • the element's ID is the value of the content - attribute, and

              • -
              • the element is type-compatible with the IDL attribute.

              • -
              -

              If no element exists which meeds both criteria, then the element has no - attr-associated element.

              +
                +
              • the element's ID is the value of the content + attribute, and

              • +
              • the element is type-compatible with the IDL attribute.

              • +
              +
            7. + +
            8. If candidate is not null, then return candidate.

            9. + +
            10. Otherwise, the element has no attr-associated element +

          • On getting, the IDL attribute must return the element's attr-associated @@ -7258,22 +7262,17 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

            On setting:

            1. -

              If the given value is:

              -
                -
              • null, or

              • -
              • not a descendant of any of the attribute's element's shadow-including ancestors,

              • -
              -

              then:

              +

              If the given value is not a descendant of any of the attribute's element's + shadow-including ancestors, + then:

              +
                -
              1. Set [[attrAssociatedElement]] to null.

              2. +
              3. Set [[attrElement]] to null.

              4. Remove the content attribute.

              5. Return.

            2. -
            3. Otherwise, set [[attrAssociatedElement]] to the given value.

            4. -
            5. Let id be the empty string.

            6. If the given element:

              @@ -7286,8 +7285,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

          then set id to the element's ID. -

        7. Set the content attribute's value to id, skipping the attribute change steps.

        8. +
        9. Set the content attribute's value to id.

        10. + +
        11. Set [[attrElement]] to the given value.

      9. @@ -7298,7 +7298,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
      10. If localName is not associated attribute’s local name, or namespace is not null, return.

      11. -
      12. Set [[attrAssociatedElement]] to null.

      13. +
      14. Set [[attrElement]] to null.

    2. @@ -7316,14 +7316,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute attr-associated elements.

    3. This attribute defines an internal slot on element named - [[attrAssociatedElements]], with an initial value of null.

    4. + [[attrElements]], with an initial value of null.

      -
    5. If the value of [[attrAssociatedElements]] is not null, the element's +

    6. If the value of [[attrElements]] is not null, the element's attr-associated elements list is the value of - [[attrAssociatedElements]].

    7. + [[attrElements]].

    8. -

      If the value of [[attrAssociatedElements]] is null, and the value of the content +

      If the value of [[attrElements]] is null, and the value of the content attribute is not null, then the element's attr-associated element is computed as follows:

        @@ -7363,7 +7363,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
      • If the given value is null:

          -
        1. Set [[attrAssociatedElements]] to null.

        2. +
        3. Set [[attrElements]] to null.

        4. Remove the content attribute.

        5. Return.

        @@ -7375,9 +7375,11 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
      • For each element in the given value:

          -
        1. If element is not type-compatible with the IDL attribute's inner type, or - is not a descendant of either the attribute's element's root or the attribute's - element's shadow-including root, then continue.

        2. +
        3. +

          If element is not a descendant of any of the attribute's + element's shadow-including + ancestors, then continue.

          +
        4. If value is empty and elements is non-empty, append element to elements and @@ -7399,8 +7401,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

          then set value to be the empty string, and continue.

        5. -
        6. Otherwise, let id be the element's ID.

        7. +
        8. Otherwise, let id be the element's ID.

        9. If value is not the empty string, append U+0020 SPACE to value.

        10. @@ -7409,7 +7411,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
      • -
      • Set [[attrAssociatedElements]] to elements.

      • +
      • Set [[attrElements]] to elements.

      • Set the content attribute's value to value, skipping the attribute change steps.

      • @@ -7423,7 +7425,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
      • If localName is not associated attribute’s local name, or namespace is not null, return.

      • -
      • Set [[attrAssociatedElements]] to null.

      • +
      • Set [[attrElements]] to null.

    From 63a45e8dfbef7f7631dff20950d81efa6a6be340 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 2 Aug 2019 13:13:36 -0400 Subject: [PATCH 15/20] Editorial tweaks to T? reflection --- source | 87 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/source b/source index d68d54f5ffe..2a1ac40b380 100644 --- a/source +++ b/source @@ -2622,6 +2622,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • include
  • inherit
  • interface prototype object
  • +
  • implements
  • [[Realm]] field of a platform object
  • callback context
  • frozen array and @@ -7221,73 +7222,82 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute whose associated attribute's local name is the name of the attribute in question.

    If a reflecting IDL attribute attr has the type Element?, or type T? where T is an interface - that inherits from Element, then: + data-x="">T?, where T is either Element or an + interface that inherits from Element, then: +

      -
    • This attribute defines an internal slot on element named - [[attrElement]], with an initial value of null;

    • +
    • Elements of the type this IDL attribute appears on have an explicitly set + attr-element, which is an element or null. It is initially null.

    • -

      The attribute's element can be associated with a particular other element, referred to as its - attr-associated element. To compute the attr-associated - element for a particular element:

      +

      Elements of the type this IDL attribute appears on have an attr-associated + element. To compute the attr-associated element for such an + element element:

        -
      1. If the value of [[attrElement]] is not null, then return the value of - [[attrElement]].

      2. +
      3. If element's explicitly set attr-element is not null, + then return element's explicitly set attr-element.

      4. -

        Otherwise, if the value of [[attrElement]] is null, and the value of the content - attribute is not null, let candidate be the first element, in tree order, within - the content attribute's element's node tree which meets the following +

        Otherwise, if the content attribute is present on element, then return the first + element candidate, in tree order, that meets the following criteria:

        -
          -
        • the element's ID is the value of the content - attribute, and

        • -
        • the element is type-compatible with the IDL attribute.

        • +
            +
          • candidate's root is the same as element's + root,
          • +
          • candidate's ID is the value of the content + attribute, and
          • +
          • candidate implements T.
          - -
        • If candidate is not null, then return candidate.

        • +

          If no such element exists, then return null.

          + -
        • Otherwise, the element has no attr-associated element +

        • Return null.

      + +

      Other parts of this specification, or other specifications using attribute + reflection, are generally expected to consult the attr-associated + element. The explicitly set attr-element is an internal + implementation detail of the attr-associated element, and is not to be + used directly.

    • -
    • On getting, the IDL attribute must return the element's attr-associated +

    • On getting, the IDL attribute must return this element's attr-associated element.

    • -

      On setting:

      +

      On setting, the IDL attribute must perform the following steps:

      1. -

        If the given value is not a descendant of any of the attribute's element's - shadow-including ancestors, - then:

        +

        If the given value is not a descendant of any of this element's shadow-including ancestors, then:

          -
        1. Set [[attrElement]] to null.

        2. -
        3. Remove the content attribute.

        4. +
        5. Set this element's explicitly set attr-element to + null.

        6. +
        7. Remove the content attribute from this element.

        8. Return.

      2. Let id be the empty string.

      3. -
      4. If the given element:

        -
          -
        • has an id attribute, and

        • -
        • has the same root as the element of the attribute being set, and

        • -
        • is the first element in the element's node tree whose

          If the given value:

          +
            +
          • has the same root as this element, and
          • +
          • has an id attribute, and
          • +
          • is the first element in this element's node tree whose ID is the value of that id - attribute,

          • + attribute,
          -

          then set id to the element's ID. +

          then set id to the given value's ID.

          -
        • Set the content attribute's value to id.

        • +
        • Set the content attribute's value for this element to id.

        • -
        • Set [[attrElement]] to the given value.

        • +
        • Set this element's explicitly set attr-element to the given + value.

    • @@ -7295,10 +7305,11 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

      The following attribute change steps are used to synchronize between the content attribute and the IDL attribute:

        -
      1. If localName is not associated attribute’s local name, or - namespace is not null, return.

      2. +
      3. If localName is not the content attribute's local name, or + namespace is not null, then return.

      4. -
      5. Set [[attrElement]] to null.

      6. +
      7. Set element's explicitly set attr-element to + null.

    From 3cc73cd09fc00ae0090b41d980eec9bf66fc58cd Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 2 Aug 2019 14:19:19 -0400 Subject: [PATCH 16/20] Editorial and slight normative tweaks to FrozenArray? reflection Normative change: previously, if a non-type-compatible element had the ID, and was before a type-compatible element in tree order that also had the ID, then neither would show up in the attr-associated elements. Now, the type-compatible one shows up. This matches the behavior of the T? reflection better. --- source | 164 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 103 insertions(+), 61 deletions(-) diff --git a/source b/source index 2a1ac40b380..7a45d798f43 100644 --- a/source +++ b/source @@ -7315,117 +7315,158 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    If a reflecting IDL attribute attr has the type FrozenArray<Element>?, or FrozenArray<T>? where T inherits from - Element, then:

    + data-x="">FrozenArray<T>?, where T is either + Element or an interface that inherits from Element, then:

      -
    • The attribute's element can be associated with a list of other elements, referred to as - its attr-associated elements.

    • +
    • Elements of the type this IDL attribute appears on have explicitly set + attr-elements, which is either a list of elements or null. It is + initially null.

    • -
    • Except where otherwise specified by the following rules, an element has no - attr-associated elements.

    • +
    • Elements of the type this IDL attribute appears on have cached + attr-associated elements, which is a FrozenArray<Element>?. It is initially null.

    • -
    • This attribute defines an internal slot on element named - [[attrElements]], with an initial value of null.

    • +
    • +

      Elements of the type this IDL attribute appears on have attr-associated elements. To compute the + attr-associated elements for such an element element:

      -
    • If the value of [[attrElements]] is not null, the element's - attr-associated elements list is the value of - [[attrElements]].

    • +
        +
      1. If element's explicitly set attr-elements is not + null, then return element's explicitly set + attr-elements.

      2. -
      3. -

        If the value of [[attrElements]] is null, and the value of the content - attribute is not null, then the element's attr-associated element is - computed as follows: -

          -
        • Let elements be an empty list.

        • +
        • Let elements be an empty list.

        • Let tokens be the content attribute's value, split on ASCII whitespace.

        • + ASCII whitespace">split on ASCII whitespace, if the content attribute is present on + element; otherwise let tokens be an empty list.

        • For each id in tokens:

          -
            -
          • Let candidate be the first element, in tree order, within the content - attribute's elements node tree whose ID is - id.

          • +
              +
            1. +

              Let candidate be the first element, in tree order, that meets the + following criteria:

              + +
                +
              • candidate's root is the same as element's + root,
              • +
              • candidate's ID is id, and
              • +
              • candidate implements T.
              • +
              -
            2. If candidate is null, or if it is not type-compatible with the IDL - attribute, then continue.

            3. +

              If no such element exists, then continue.

              + -
            4. Otherwise, append candidate to elements.

            5. -
          +
        • Append candidate to + elements.

        • +
      -
    • If elements is empty, then the element has no - attr-associated elements.

    • +
    • If elements is empty, then set + elements to null.

    • -
    • Otherwise, the element's attr-associated elements is - elements.

    • -
    +
  • Return elements.

  • + + +

    Other parts of this specification, or other specifications using attribute + reflection, are generally expected to consult the attr-associated + elements. The explicitly set attr-elements are an internal + implementation detail of the attr-associated elements, and are not to be + used directly. Similarly, the cached attr-associated elements are an + internal implementation detail of the IDL attribute's getter.

    -
  • On getting, the IDL attribute must return the element's attr-associated - element, or null if it does not exist.

  • +
  • +

    On getting, the IDL attribute must perform the following steps:

    + +
      +
    1. Let elements be this element's attr-associated + elements.

    2. + +
    3. If the contents of elements is equal to the contents of this element's + cached attr-associated elements, then return this element's + cached attr-associated elements.

    4. + +
    5. Let elementsAsFrozenArray be elements, converted to a FrozenArray<T>?.

    6. + +
    7. Set this element's cached attr-associated elements to + elementsAsFrozenArray.

    8. + +
    9. Return elementsAsFrozenArray.

    10. +
    + +

    This extra caching layer is necessary to preserve the invariant that element.reflectedElements === element.reflectedElements.

    +
  • -

    On setting:

    +

    On setting, the IDL attribute must perform the following steps:

    1. If the given value is null:

        -
      1. Set [[attrElements]] to null.

      2. -
      3. Remove the content attribute.

      4. +
      5. Set this element's explicitly set attr-elements to + null.

      6. + +
      7. Remove the content attribute from this element.

      8. +
      9. Return.

    2. -
    3. Let elements be an empty list, and value be an empty - string.

    4. +
    5. Let elements be an empty list.

    6. + +
    7. Let value be an empty string.

    8. For each element in the given value:

      1. -

        If element is not a descendant of any of the attribute's - element's shadow-including - ancestors, then continue.

        +

        If element is not a descendant of any of this element's shadow-including ancestors, then + continue.

      2. -
      3. If value is empty and elements is non-empty, append element to elements and +

      4. If value is empty and elements is non-empty, then append element to elements and continue.

      5. -
      6. Otherwise, append element to +

      7. Append element to elements.

      8. -

        If the given element:

        -
          -
        • has no id attribute, or

        • -
        • does not have the same root as the element of the attribute being set, - or

        • -
        • is not the first element in the element's node tree whose If element:

          + +
            +
          • does not have the same root as this element, or
          • +
          • has no id attribute, or
          • +
          • is not the first element in this element's node tree whose ID is the value of that id - attribute,

          • + attribute,
          -

          then set value to be the empty string, and continue.

          + +

          then set value to the empty string, and continue.

        • -
        • Otherwise, let id be the element's

          Let id be element's ID.

        • -
        • If value is not the empty string, append U+0020 SPACE to +

        • If value is not the empty string, then append U+0020 SPACE to value.

        • Append id to value.

    9. -
    10. Set [[attrElements]] to elements.

    11. +
    12. Set the content attribute's value for this element to value.

    13. -
    14. Set the content attribute's value to value, skipping the attribute change steps.

    15. +
    16. Set this element's explicitly set attr-elements to + elements.

  • @@ -7433,10 +7474,11 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    The following attribute change steps are used to synchronize between the content attribute and the IDL attribute:

      -
    1. If localName is not associated attribute’s local name, or - namespace is not null, return.

    2. +
    3. If localName is not the content attribute's local name, or + namespace is not null, then return.

    4. -
    5. Set [[attrElements]] to null.

    6. +
    7. Set element's explicitly set attr-elements to + null.

    From 003e30711e50e007baa74be66656354ed7256bf9 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Wed, 28 Oct 2020 21:18:38 +1100 Subject: [PATCH 17/20] Update based on AOM discussions --- source | 119 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 63 insertions(+), 56 deletions(-) diff --git a/source b/source index 7a45d798f43..20d663dcecc 100644 --- a/source +++ b/source @@ -7235,8 +7235,16 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute element element:

      -
    1. If element's explicitly set attr-element is not null, - then return element's explicitly set attr-element.

    2. +
    3. +

      If element's explicitly set attr-element is not null:

      +
        +
      • If element's explicitly set attr-element is a + descendant of any of element's shadow-including ancestors, then return + element's explicitly set attr-element.

      • +
      • Otherwise, return null.

      • +
      +
    4. Otherwise, if the content attribute is present on element, then return the first @@ -7245,7 +7253,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

      • candidate's root is the same as element's - root,
      • + root,
      • candidate's ID is the value of the content attribute, and
      • candidate implements T.
      • @@ -7270,18 +7278,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
      • On setting, the IDL attribute must perform the following steps:

          -
        1. -

          If the given value is not a descendant of any of this element's shadow-including ancestors, then:

          - -
            -
          1. Set this element's explicitly set attr-element to - null.

          2. -
          3. Remove the content attribute from this element.

          4. -
          5. Return.

          6. -
          -
        2. -
        3. Let id be the empty string.

        4. If the given value:

          @@ -7333,44 +7329,63 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute attr-associated elements for such an element element:

            -
          1. If element's explicitly set attr-elements is not - null, then return element's explicitly set - attr-elements.

          2. +
          3. Let elements be an empty list.

          4. -
          5. Let elements be an empty list.

          6. - -
          7. Let tokens be the content attribute's value, split on ASCII whitespace, if the content attribute is present on - element; otherwise let tokens be an empty list.

          8. - -
          9. -

            For each id in tokens:

            -
              -
            1. -

              Let candidate be the first element, in tree order, that meets the - following criteria:

              - -
                -
              • candidate's root is the same as element's - root,
              • -
              • candidate's ID is id, and
              • -
              • candidate implements T.
              • -
              - -

              If no such element exists, then continue.

              -
            2. +
            3. +

              If element's explicitly set attr-elements is not + null, then:

              +
                +
              1. +

                For each attrElement in the element's + explicitly set attr-elements:

                +
                  +
                1. If attrElement is not a descendant of any of element's shadow-including ancestors, then + continue.

                2. +
                3. Add attrElement to elements.

                4. +
                +
              2. +
              +
            4. +
            5. +

              Otherwise:

              +
                +
              1. Let tokens be the content attribute's value, split on ASCII whitespace, if the content attribute is present on + element; otherwise let tokens be an empty list.

              2. -
              3. Append candidate to - elements.

              4. -
              -
            6. +
            7. +

              For each id in tokens:

              +
                +
              1. +

                Let candidate be the first element, in tree order, that meets the + following criteria:

                + +
                  +
                • candidate's root is the same as element's + root,
                • +
                • candidate's ID is id, and
                • +
                • candidate implements T.
                • +
                + +

                If no such element exists, then continue.

                +
              2. + +
              3. Append candidate to + elements.

              4. +
              +
            8. +
            +
          10. -
          11. If elements is empty, then set - elements to null.

          12. +
          13. If elements is empty, then set + elements to null.

          14. -
          15. Return elements.

          16. -
          +
        5. Return elements.

        6. +
        +
      • +
      • Other parts of this specification, or other specifications using attribute reflection, are generally expected to consult the attr-associated elements. The explicitly set attr-elements are an internal @@ -7419,19 +7434,11 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    -
  • Let elements be an empty list.

  • -
  • Let value be an empty string.

  • For each element in the given value:

      -
    1. -

      If element is not a descendant of any of this element's shadow-including ancestors, then - continue.

      -
    2. -
    3. If value is empty and elements is non-empty, then append element to elements and continue.

    4. From ca6d62dcaaa2c6f1750010d97ed2f324df9a7f40 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Tue, 30 Mar 2021 16:23:19 +1100 Subject: [PATCH 18/20] Remove references to cached attr-elements --- source | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/source b/source index 20d663dcecc..fcacbfe97e2 100644 --- a/source +++ b/source @@ -7319,10 +7319,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute attr-elements, which is either a list of elements or null. It is initially null.

      -
    5. Elements of the type this IDL attribute appears on have cached - attr-associated elements, which is a FrozenArray<Element>?. It is initially null.

    6. -
    7. Elements of the type this IDL attribute appears on have attr-associated elements. To compute the @@ -7390,8 +7386,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute reflection, are generally expected to consult the attr-associated elements. The explicitly set attr-elements are an internal implementation detail of the attr-associated elements, and are not to be - used directly. Similarly, the cached attr-associated elements are an - internal implementation detail of the IDL attribute's getter.

      + used directly.

    8. @@ -7401,22 +7396,13 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
    9. Let elements be this element's attr-associated elements.

    10. -
    11. If the contents of elements is equal to the contents of this element's - cached attr-associated elements, then return this element's - cached attr-associated elements.

    12. -
    13. Let elementsAsFrozenArray be elements, converted to a FrozenArray<T>?.

    14. -
    15. Set this element's cached attr-associated elements to - elementsAsFrozenArray.

    16. -
    17. Return elementsAsFrozenArray.

    -

    This extra caching layer is necessary to preserve the invariant that element.reflectedElements === element.reflectedElements.

  • From 228b604b6449267ed1b0df363b2a07ffaf2f1463 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Wed, 31 Mar 2021 13:33:03 +1100 Subject: [PATCH 19/20] Revert "Remove references to cached attr-elements" This reverts commit ca6d62dcaaa2c6f1750010d97ed2f324df9a7f40. --- source | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/source b/source index fcacbfe97e2..20d663dcecc 100644 --- a/source +++ b/source @@ -7319,6 +7319,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute attr-elements, which is either a list of elements or null. It is initially null.

  • +
  • Elements of the type this IDL attribute appears on have cached + attr-associated elements, which is a FrozenArray<Element>?. It is initially null.

  • +
  • Elements of the type this IDL attribute appears on have attr-associated elements. To compute the @@ -7386,7 +7390,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute reflection, are generally expected to consult the attr-associated elements. The explicitly set attr-elements are an internal implementation detail of the attr-associated elements, and are not to be - used directly.

    + used directly. Similarly, the cached attr-associated elements are an + internal implementation detail of the IDL attribute's getter.

  • @@ -7396,13 +7401,22 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • Let elements be this element's attr-associated elements.

  • +
  • If the contents of elements is equal to the contents of this element's + cached attr-associated elements, then return this element's + cached attr-associated elements.

  • +
  • Let elementsAsFrozenArray be elements, converted to a FrozenArray<T>?.

  • +
  • Set this element's cached attr-associated elements to + elementsAsFrozenArray.

  • +
  • Return elementsAsFrozenArray.

  • +

    This extra caching layer is necessary to preserve the invariant that element.reflectedElements === element.reflectedElements.

  • From b2ce05796c147eb6311c24a9424cbec8a68c4d87 Mon Sep 17 00:00:00 2001 From: Alice Boxhall Date: Tue, 6 Apr 2021 19:08:09 +1000 Subject: [PATCH 20/20] Return null if the attribute is not present, and empty array instead of null if zero values --- source | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/source b/source index 20d663dcecc..7810b777713 100644 --- a/source +++ b/source @@ -7350,9 +7350,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • Otherwise:

      +
    1. If the content attribute is not present on element, return null.

    2. +
    3. Let tokens be the content attribute's value, split on ASCII whitespace, if the content attribute is present on - element; otherwise let tokens be an empty list.

    4. + ASCII whitespace">split on ASCII whitespace.
    5. For each id in tokens:

      @@ -7378,9 +7379,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • -
  • If elements is empty, then set - elements to null.

  • -
  • Return elements.