From a9d0db46c1303e99837c33e54c59b3b8c2743f9a Mon Sep 17 00:00:00 2001 From: Alice Boxhall <95208+alice@users.noreply.github.com> Date: Tue, 4 Feb 2025 15:33:03 +1100 Subject: [PATCH 01/20] Begin exploring how to specify what effect referenceTarget has. --- source | 153 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 98 insertions(+), 55 deletions(-) diff --git a/source b/source index 213f90acbef..8db11ea396b 100644 --- a/source +++ b/source @@ -5187,6 +5187,85 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute +

Element reference attributes

+ +

+ Element reference attributes refer to one or more Elements in the document.

+ +

The steps to resolve the reference + target on an element element referred to by an element reference attribute + are:

+ +
    +
  1. If element does not have a shadow root, or element's + shadow root doesn't have a referenceTarget + property, return element.

  2. + +
  3. Let referenceTarget be the value of element's shadow + root's referenceTarget property

  4. + +
  5. Let candidate be the first element in element's shadow + root whose ID matches referenceTarget.

    +
  6. + +
  7. If no such element exists, return null.

  8. + +
  9. Return the result of resolving the reference + target on candidate. +

  10. +
+ +
Single element reference attributes
+ +

Single element reference attributes refer to a single Element.

+ +

The rules to get the + attr-associated element for an element reference attribute attr and + element element, are:

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

  2. + +
  3. +

    If element has an explicitly-set + attr-element which is not null:

    + +
      +
    1. If element's explicitly-set + attr-element is a descendant of any of element's + shadow-including ancestors, then let + candidate be element's + explicitly-set attr-element.

      +
    2. + +
    3. Otherwise, let candidate be null.

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

    Otherwise: + +

      +
    1. Let value be the attribute value.

    2. + +
    3. Let candidate be the first element in element's tree, + in tree order whose ID is value.

      +
    4. + +
    5. If no such element exists, let candidate be null.

      +
    6. +
    +
  6. + +
  7. If candidate is null, return null.
  8. + +
  9. Return the result of resolving the reference + target on candidate. +

  10. +
+

Numbers

@@ -8519,59 +8598,23 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute name:

For those, specification authors must use the reflected target's - get the attr-associated element and get the - attr-associated elements, respectively. The content attribute presence and value - must not be used as they cannot be fully synchronized with the reflected IDL - attribute.

+ get the attr-associated element + and get the attr-associated elements, respectively. The content attribute + presence and value must not be used as they cannot be fully synchronized with the reflected + IDL attribute.

A reflected target's explicitly set attr-element, explicitly set attr-elements, cached attr-associated @@ -46424,11 +46467,11 @@ interface HTMLLabelElement : HTMLElement { be specified to indicate a form control with which the caption is to be associated. If the attribute is specified, the attribute's value must be the ID of a labelable element in the same tree as the - label element. If the attribute is specified and there is an element in - the tree whose ID is equal to the value of the for attribute, and the first such element in tree - order is a labelable element, then that element is the - label element's labeled control.

+ label element. If the attribute is specified, the for-associated element is not null, and the for-associated element is a labelable element, then that element is the label + element's labeled control.

From 1ade6e09648e4cc5b50d3d21c66cb7b3f91d33d0 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Wed, 5 Feb 2025 01:38:23 +0000 Subject: [PATCH 02/20] Add shadowrootreferencetarget attribute to template, plumb it through to shadow creation --- source | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/source b/source index 864a982e0de..a617d4eb083 100644 --- a/source +++ b/source @@ -3203,7 +3203,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • node document concept
  • document type concept
  • host concept
  • -
  • The shadow root concept, and its delegates focus, available to element internals, clonable, and serializable.
  • +
  • The shadow root concept, and its delegates focus, available to element internals, clonable, serializable, and reference target
  • The shadow host concept
  • HTMLCollection interface, its length attribute, and its @@ -64320,6 +64320,7 @@ not-slash = %x0000-002E / %x0030-10FFFF
    shadowrootdelegatesfocus
    shadowrootclonable
    shadowrootserializable
    +
    shadowrootreferencetarget
    Accessibility considerations:
    For authors.
    @@ -64335,6 +64336,7 @@ interface HTMLTemplateElement : HTMLElement { [CEReactions] attribute boolean shadowRootDelegatesFocus; [CEReactions] attribute boolean shadowRootClonable; [CEReactions] attribute boolean shadowRootSerializable; + [CEReactions] attribute DOMString? shadowRootReferenceTarget; };
    Uses HTMLTemplateElement.
    @@ -64383,6 +64385,11 @@ interface HTMLTemplateElement : HTMLElement { data-x="attr-template-shadowrootserializable">shadowrootserializable content attribute is a boolean attribute.

    +

    The shadowrootreferencetarget content + attribute can be set to create a declarative shadow root with the given + reference target.

    +

    The template contents of a template element are not children of the element itself.

    @@ -64535,6 +64542,11 @@ interface HTMLTemplateElement : HTMLElement { must reflect the shadowrootserializable content attribute.

    +

    The shadowRootReferenceTarget IDL + attribute must reflect the + shadowrootreferencetarget content attribute.

    +

    The cloning steps for template @@ -130641,6 +130653,10 @@ document.body.appendChild(text); data-x="attr-template-shadowrootdelegatesfocus">shadowrootdelegatesfocus attribute; otherwise false.

  • +
  • Let referenceTarget be the value of the template start tag's + shadowrootreferencetarget + attribute if it has one; otherwise null.

  • +
  • If declarative shadow host element is a shadow host, then insert an element at the adjusted insertion location with template.

  • @@ -130652,7 +130668,8 @@ document.body.appendChild(text);
  • Attach a shadow root with declarative shadow host element, mode, clonable, - serializable, delegatesFocus, and "named".

    + serializable, delegatesFocus, "named", + and referenceTarget.

    If an exception is thrown, then catch it and:

    @@ -134480,6 +134497,9 @@ document.body.appendChild(text);
  • If shadow's clonable is set, then append " shadowrootclonable=""".

  • +
  • If shadow's reference target is set, then append + " shadowrootreferencetarget=""".

  • +
  • Append ">".

  • Append the value of running the HTML fragment serialization algorithm with @@ -143628,6 +143648,11 @@ interface External { Enables streaming declarative shadow roots "open"; "closed" + + shadowrootreferencetarget + template + Sets reference target on a declarative shadow root + ID or null shadowrootserializable template From cd247ab01c96b342dd890a7350c15c8b7723e40a Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Wed, 5 Feb 2025 23:05:52 +0000 Subject: [PATCH 03/20] Use 'reference target' internal definition on Shadow instead of IDL property --- source | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source b/source index 80eae816b76..99633ec6521 100644 --- a/source +++ b/source @@ -5198,11 +5198,11 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    1. If element does not have a shadow root, or element's - shadow root doesn't have a referenceTarget - property, return element.

    2. + shadow root's reference target is null, return element.

      +
    3. Let referenceTarget be the value of element's shadow - root's referenceTarget property

    4. + root's reference target.

    5. Let candidate be the first element in element's shadow root whose ID matches referenceTarget.

      From 30629787490993656e9cd9ccbde352ae5d8ccae5 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Thu, 6 Feb 2025 00:25:55 +0000 Subject: [PATCH 04/20] Implicit label association accounts for reference target --- source | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/source b/source index 99633ec6521..35c155c2ab2 100644 --- a/source +++ b/source @@ -46452,14 +46452,40 @@ interface HTMLLabelElement : HTMLElement {

      The label element represents a caption in a user interface. The caption can be associated with a specific form control, known as the - label element's labeled control, either using the label element's labeled control, either using the for attribute, or by putting the form control inside the label element itself.

      -

      Except where otherwise specified by the following rules, a label element has no - labeled control.

      +

      To determine a label element's labeled control, run these steps:

      + +
        +
      1. +

        If the label's for attribute is + specified, then:

        + +
          +
        1. If the for-associated element is not null, and the for-associated element is a labelable element, return that element.

        2. + +
        3. Otherwise, return null.

        4. +
        +
      2. + +
      3. For each descendant candidate of the + label in tree order:

      4. + +
          +
        1. If the result of resolving the reference + target on candidate is a + labelable element, return candidate.

        2. +
        + +
      5. Return null.

      6. +
      @@ -46467,11 +46493,7 @@ interface HTMLLabelElement : HTMLElement { be specified to indicate a form control with which the caption is to be associated. If the attribute is specified, the attribute's value must be the ID of a labelable element in the same tree as the - label element. If the attribute is specified, the for-associated element is not null, and the for-associated element is a labelable element, then that element is the label - element's labeled control.

      + label element.

      From 1bcd135a7edc3a1f1a9ee40de90b696d2c8ae2e5 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Thu, 6 Feb 2025 00:44:53 +0000 Subject: [PATCH 05/20] Don't directly nest
        s --- source | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/source b/source index 35c155c2ab2..16b3d198792 100644 --- a/source +++ b/source @@ -46475,14 +46475,16 @@ interface HTMLLabelElement : HTMLElement {
    6. -
    7. For each descendant candidate of the - label in tree order:

    8. +
    9. +

      For each descendant candidate of the + label in tree order:

      -
        -
      1. If the result of resolving the reference - target on candidate is a - labelable element, return candidate.

      2. -
      +
        +
      1. If the result of resolving the reference + target on candidate is a + labelable element, return candidate.

      2. +
      +
    10. Return null.

    From 85e7f191036a688611841dfad1a913402724adbb Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Thu, 13 Feb 2025 00:59:22 +0000 Subject: [PATCH 06/20] Actually return the resolved reference target from labeled control algo --- source | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source b/source index 16b3d198792..911baa780a3 100644 --- a/source +++ b/source @@ -46476,13 +46476,16 @@ interface HTMLLabelElement : HTMLElement {
  • -

    For each descendant candidate of the +

    For each descendant descendant of the label in tree order:

      -
    1. If the result of resolving the reference - target on candidate is a - labelable element, return candidate.

    2. +
    3. Let candidate be the result of + resolving the reference target on + descendant.

    4. + +
    5. If candidate is a labelable element, + return candidate.

  • From 9fe4ad667e34e8b451f7a2bde51aa0eea0181f58 Mon Sep 17 00:00:00 2001 From: Alice Boxhall <95208+alice@users.noreply.github.com> Date: Fri, 14 Feb 2025 16:30:05 +1100 Subject: [PATCH 07/20] Add a section about multiple element reference attributes --- source | 191 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 113 insertions(+), 78 deletions(-) diff --git a/source b/source index 911baa780a3..6e4529996d4 100644 --- a/source +++ b/source @@ -5190,7 +5190,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    Element reference attributes

    - Element reference attributes refer to one or more Elements in the document.

    + Element reference attributes refer to one or more Elements in the document. When specified + as content attributes, element reference attributes refer to other Elements via their + IDs.

    The steps to resolve the reference target on an element element referred to by an element reference attribute @@ -5218,7 +5220,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    Single element reference attributes

    Single element reference attributes refer to a single Element.

    + export>Single element reference attributes refer to a single Element. When specified as a + content attribute, a single element reference attribute consists of a single token + which should completely match the ID of another element in the + document.

    The rules to get the attr-associated element for an element reference attribute attr and @@ -5266,6 +5271,99 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    +
    Multiple element reference attributes
    + +

    Multiple element reference attributes + refer to multiple Elements. When specified as a content attribute, a multiple element + reference attribute consists of space-separated tokens, each of which should completely + match the ID of another element in the document.

    + +

    The rules to get the attr-associated + elements for a multiple element reference attribute attr and element + elementare:

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

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

    4. + +
    5. +

      If element's has an explicitly set attr-elements which + is not null:

      + +
        +
      1. +

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

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

        2. + +
        3. Append attrElement to + candidates.

        4. +
        +
      2. +
      +
    6. + +
    7. +

      Otherwise:

      + +
        +
      1. Let value be the attribute value.

      2. + +
      3. Let tokens be value, split on ASCII whitespace. + +

      4. +

        For each id of 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 + candidates.

        4. +
        +
      5. +
      +
    8. + +
    9. Let resolvedCandidates be an empty list.

    10. + +
    11. +

      For each candidate in candidates: +

      + +
        +
      1. Let resolvedCandidate be the result of + resolving the reference target on + candidate.

      2. + +
      3. If resolvedCandidate is not null, append resolvedCandidate to + resolvedCandidates.

      4. +
      +
    12. + +
    13. Return resolvedCandidates.

    14. +

    Numbers

    @@ -8679,98 +8777,35 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute initially null.

  • -

    Its reflected target reflectedTarget has a get the - attr-associated elements algorithm, which runs these steps:

    +

    The getter steps are:

      -
    1. Let elements be an empty list.

    2. +
    3. Let elements be the result of running this's get the + attr-associated elements.

    4. -
    5. Let element be the result of running reflectedTarget's get - the element.

    6. +
    7. Let retargetedElements be an empty list.

    8. -

      If reflectedTarget's explicitly set attr-elements is not - null:

      +

      For each element in elements:

        -
      1. -

        For each attrElement in - reflectedTarget's explicitly set attr-elements:

        +
      2. Let retargetedElement be the result of retargeting element against this.

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

        2. - -
        3. Append attrElement to - elements.

        4. -
        - +
      4. Append retargetedElement to retargetedElements.

    9. -
    10. -

      Otherwise:

      - -
        -
      1. Let contentAttributeValue be the result of running - reflectedTarget's get the content attribute. - -

      2. If contentAttributeValue is null, then return null.

      3. - -
      4. Let tokens be contentAttributeValue, split on ASCII whitespace. +

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

      6. -
      7. -

        For each id of 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. -
      -
    11. - -
    12. Return elements.

    13. -
    -
  • - -
  • -

    The getter steps are:

    - -
      -
    1. Let elements be the result of running this's get the - attr-associated elements.

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

    4. - -
    5. Let elementsAsFrozenArray be elements,

      Let elementsAsFrozenArray be retargetedElements, converted to a FrozenArray<T>?.

    6. Set this's cached attr-associated elements to - elements.

    7. + retargetedElements.

    8. Set this's cached attr-associated elements object to elementsAsFrozenArray.

    9. From 28acb5c6cabbdbf0c71fb5bd178a021319222c44 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Wed, 19 Feb 2025 03:44:17 +0000 Subject: [PATCH 08/20] Fix element reference attribute definition --- source | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source b/source index 58a017a2f8c..062b98dd805 100644 --- a/source +++ b/source @@ -5189,14 +5189,15 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

      Element reference attributes

      -

      - Element reference attributes refer to one or more Elements in the document. When specified - as content attributes, element reference attributes refer to other Elements via their - IDs.

      +

      + Element reference attributes refer to one or more Elements in the document. When specified + as content attributes, element reference attributes refer to other Elements + via their IDs.

      The steps to resolve the reference - target on an element element referred to by an element reference attribute - are:

      + target on an element element referred to by an + element reference attribute are:

      1. If element does not have a shadow root, or element's From d6fbcfd621f28da035307e0c243765963006b6e2 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Mon, 3 Mar 2025 19:13:07 +0000 Subject: [PATCH 09/20] Update HTMLLabelElement control and form properties --- source | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/source b/source index 062b98dd805..b02212c6ae6 100644 --- a/source +++ b/source @@ -46478,7 +46478,7 @@ interface HTMLFormElement : HTMLElement { interface HTMLLabelElement : HTMLElement { [HTMLConstructor] constructor(); - readonly attribute HTMLFormElement? form; + readonly attribute HTMLElement? form; [CEReactions] attribute DOMString htmlFor; readonly attribute HTMLElement? control; }; @@ -46617,8 +46617,15 @@ interface HTMLLabelElement : HTMLElement { attribute.

        The control - IDL attribute must return the label element's labeled control, if any, - or null if there isn't one.

        + IDL attribute must run the following steps:

        + +
          +
        1. If the label element has no labeled control, then return + null.

        2. + +
        3. Return the result of retargeting the label + element's labeled control against the label element.

        4. +

        The form IDL attribute must run the following steps:

        @@ -46630,8 +46637,12 @@ interface HTMLLabelElement : HTMLElement {
      2. If the label element's labeled control is not a form-associated element, then return null.

      3. -
      4. Return the label element's labeled control's form - owner (which can still be null).

      5. +
      6. If the label element's labeled control's form + owner is null, return null.

      7. + +
      8. Return the result of retargeting the + label element's labeled control's form owner against the + label element.

  • From e964930bc9f14f0ad8e777087eee832c92da832f Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Mon, 3 Mar 2025 19:43:00 +0000 Subject: [PATCH 10/20] Update the HTMLInputElement.list attribute --- source | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/source b/source index b02212c6ae6..32106c8a848 100644 --- a/source +++ b/source @@ -46879,7 +46879,7 @@ interface HTMLInputElement : HTMLElement { [CEReactions] attribute DOMString formTarget; [CEReactions] attribute unsigned long height; attribute boolean indeterminate; - readonly attribute HTMLDataListElement? list; + readonly attribute HTMLElement? list; [CEReactions] attribute DOMString max; [CEReactions] attribute long maxLength; [CEReactions] attribute DOMString min; @@ -52660,19 +52660,17 @@ You cannot submit this form when the field is incorrect.

    The list attribute is used to identify an element that lists predefined options suggested to the user.

    -

    If present, its value must be the ID of a datalist - element in the same tree.

    +

    If present, its value must be the ID of an element in the same + tree for which the result of resolving + the reference target is a datalist.

    -

    The suggestions source element is the first element in - the tree in tree order to have an ID - equal to the value of the list attribute, if that element - is a datalist element. If there is no list - attribute, or if there is no element with that ID, or if the - first element with that ID is not a datalist - element, then there is no suggestions source - element.

    +

    The suggestions source element is the list-associated element, if that element + is a datalist element. If the + list-associated element is null or is not a datalist element, then there is + no suggestions source element.

    If there is a suggestions source element, then, when the user agent is allowing the user to edit the input element's


    The list IDL - attribute must return the current suggestions source - element, if any, or null otherwise.

    + attribute must reflect the list content attribute.


    From 004f71b0684bc2d3db6291724b161c7b90a75949 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Mon, 3 Mar 2025 23:44:56 +0000 Subject: [PATCH 11/20] Update headers property --- source | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/source b/source index 32106c8a848..16861476d5a 100644 --- a/source +++ b/source @@ -44227,18 +44227,23 @@ interface HTMLTableCellElement : HTMLElement { data-x="attr-tdth-headers">headers attribute, if specified, must contain a string consisting of an unordered set of unique space-separated tokens, none of which are identical to another token and each of which must have the value of an ID of a th element taking part in the same table as the td or th element (as defined by the table model).

    - -

    A th element with ID id is - said to be directly targeted by all td and th elements in the - same table that have headers attributes whose values include as one of their tokens - the ID id. A th element A is said to be targeted by a th or td element - B if either A is directly targeted by B or if there exists an element C that is itself - targeted by the element B and A is directly - targeted by C.

    + data-x="concept-id">ID of an element for which the result of + resolving the reference target on that element + is a th element taking part in the same table as + the td or th element (as defined by the + table model).

    + +

    A th element X is said to be directly targeted by a + td or th element Y in the same table if Y has a headers attribute whose value includes as one of its tokens an + ID id such that resolving the reference target on any element + Z with ID id is X. A + th element A is said to be targeted by a th or + td element B if either A is directly targeted by + B or if there exists an element C that is itself targeted by the + element B and A is directly targeted by C.

    A th element must not be targeted by itself.

    @@ -44842,14 +44847,14 @@ interface HTMLTableCellElement : HTMLElement {
  • - - -

    For each token in the id list, if the - first element in the Document with an ID equal to - the token is a cell in the same table, and that cell is not the - principal cell, then add that cell to header list.

    -
  • + + +

    For each token in the id list, if the result of resolving the reference target on the first + element in the Document with an ID equal to + the token is a cell in the same table, and that cell is + not the principal cell, then add that cell to header list.

    + From 7f840159a2aaff2f61bd40f352d74ef8576a2dde Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Thu, 6 Mar 2025 01:19:01 +0000 Subject: [PATCH 12/20] Update form association --- source | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/source b/source index 16861476d5a..29b7caaef8c 100644 --- a/source +++ b/source @@ -56466,6 +56466,12 @@ interface HTMLLegendElement : HTMLElement { any of the elements in the tree changes, then the user agent must reset the form owner of that form-associated element.

    +

    When a listed form-associated element has a + form attribute and the reference target of the + shadow root of any shadow host element in the same flat + tree changes, then the user agent must reset the form owner of that + form-associated element.

    +

    When a listed form-associated element has a form attribute and an element with an ID is inserted @@ -56506,13 +56512,17 @@ interface HTMLLegendElement : HTMLElement { data-x="attr-fae-form">form content attribute, and is connected, then:

      -
    1. If the first element in element's tree, in tree - order, to have an ID that is identical to - element's form content attribute's value, is a - form element, then associate the - element with that form element.

    2. +
    3. Let candidate be the result of resolving the reference target on the first + element in element's tree, in tree order, to have an ID that is identical to element's form content attribute's value.

    4. + case sensitive) --> + +
    5. If candidate is a form element, then associate the element with that + form element.

    From 7c5c79905635b2b6cdb40cddf49b2f64349f28c9 Mon Sep 17 00:00:00 2001 From: Alice Boxhall <95208+alice@users.noreply.github.com> Date: Thu, 6 Mar 2025 14:03:10 +1100 Subject: [PATCH 13/20] Define headers and list attributes in terms of element reference attribute concepts. --- source | 74 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/source b/source index 16861476d5a..42d62922e76 100644 --- a/source +++ b/source @@ -5193,11 +5193,13 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute Element reference attributes refer to one or more Elements in the document. When specified as content attributes, element reference attributes refer to other Elements - via their IDs.

    + via their IDs. + Element reference attributes may refer to a + single element, or to + multiple elements.

    The steps to resolve the reference - target on an element element referred to by an - element reference attribute are:

    + target on an element element are:

    1. If element does not have a shadow root, or element's @@ -5282,7 +5284,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

      The rules to get the attr-associated elements for a multiple element reference attribute attr and element - elementare:

      + element are:

      1. If the attribute is not specified on element, return null.

      2. @@ -44224,26 +44226,28 @@ interface HTMLTableCellElement : HTMLElement {

        The td and th element may have a headers content attribute specified. The headers attribute, if specified, must contain a string - consisting of an unordered set of unique space-separated tokens, none of which are - identical to another token and each of which must have the value of an ID of an element for which the result of - resolving the reference target on that element - is a th element taking part in the same table as - the td or th element (as defined by the - table model).

        + data-x="attr-tdth-headers">headers attribute, if specified, must be a valid + multiple element reference attribute + such that, for the list elements of + headers-associated elements:

        + +
          +
        • each element in elements only appears once, and

        • +
        • each element in elements is a th element taking part in the same + table as the td or th + element (as defined by the table model).

        • +

        A th element X is said to be directly targeted by a td or th element Y in the same table if Y has a headers attribute whose value includes as one of its tokens an - ID id such that resolving the reference target on any element - Z with ID id is X. A - th element A is said to be targeted by a th or - td element B if either A is directly targeted by - B or if there exists an element C that is itself targeted by the - element B and A is directly targeted by C.

        + data-x="concept-table">table if Y's + + headers-associated elements includes + X. A th element A is said to be targeted by a + th or td element B if either A is + directly targeted by B or if there exists an element C that is itself + targeted by the element B and A is directly targeted by + C.

        A th element must not be targeted by itself.

        @@ -44840,20 +44844,12 @@ interface HTMLTableCellElement : HTMLElement {
        1. -

          Take the value of the principal cell's headers attribute and split it on ASCII whitespace, letting id list be the - list of tokens obtained.

          -
        2. - -
        3. - - -

          For each token in the id list, if the result of resolving the reference target on the first - element in the Document with an ID equal to - the token is a cell in the same table, and that cell is - not the principal cell, then add that cell to header list.

          +

          For each element in the principal cell's + + headers-associated elements, if + element is a cell in the same table, and that + cell is not the principal cell, then add element to + header list.

        @@ -52665,9 +52661,11 @@ You cannot submit this form when the field is incorrect.

        The list attribute is used to identify an element that lists predefined options suggested to the user.

        -

        If present, its value must be the ID of an element in the same - tree for which the result of resolving - the reference target is a datalist.

        +

        If present, its value must a valid single + element reference attribute such that the + + list-associated element is a + datalist.

        From d35e5af971e289ee0d5a12070cdabcd33f49dd25 Mon Sep 17 00:00:00 2001 From: Alice Boxhall <95208+alice@users.noreply.github.com> Date: Thu, 6 Mar 2025 17:16:04 +1100 Subject: [PATCH 14/20] Update output-for and popover, and reword definitions --- source | 109 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/source b/source index 42d62922e76..c6be73c7043 100644 --- a/source +++ b/source @@ -5194,9 +5194,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute as content attributes, element reference attributes refer to other Elements via their IDs. - Element reference attributes may refer to a - single element, or to - multiple elements.

        The steps to resolve the reference target on an element element are:

        @@ -5220,17 +5217,22 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

      -
      Single element reference attributes
      +
      Single element references
      -

      Single element reference attributes refer to a single Element. When specified as a - content attribute, a single element reference attribute consists of a single token - which should completely match the ID of another element in the - document.

      +

      A single element reference attribute represents a reference to a single element. + When specified as a content attribute, a single element reference consists of a + single token which should completely match the ID of another + element in the document.

      + +

      A single element reference attribute attr on an element X + refers to an element Y + if Y is the attr-associated + element for X.

      The rules to get the - attr-associated element for an element reference attribute attr and - element element, are:

      + attr-associated element for a single element reference attribute + attr and element element, are:

      1. If the attribute is not specified on element, return null.

      2. @@ -5274,17 +5276,31 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

      -
      Multiple element reference attributes
      +
      Sets of element references
      + +

      A set of element references attribute represents + a set of references to elements. When specified as a content attribute, a set of element + references consists of a set of space-separated tokens, each of which should + completely match the ID of another element in the document.

      -

      Multiple element reference attributes - refer to multiple Elements. When specified as a content attribute, a multiple element - reference attribute consists of space-separated tokens, each of which should completely - match the ID of another element in the document.

      +

      An unordered set of unique element + references is a set of element references where none of the element references + is repeated.

      -

      The rules to get the attr-associated - elements for a multiple element reference attribute attr and element - element are:

      +

      An ordered set of unique element + references is a set of element references where none of the element references + is repeated, and the order of the elements is meaningful.

      + +

      A set of element references attribute attr on an element X + refers to an element Y + if Y is one of the + attr-associated elements for + X.

      + +

      The rules to get the attr-associated elements for a set of + element references attribute attr and element element are:

      1. If the attribute is not specified on element, return null.

      2. @@ -44227,27 +44243,21 @@ interface HTMLTableCellElement : HTMLElement {

        The td and th element may have a headers content attribute specified. The headers attribute, if specified, must be a valid - multiple element reference attribute - such that, for the list elements of - headers-associated elements:

        - -
          -
        • each element in elements only appears once, and

        • -
        • each element in elements is a th element taking part in the same - table as the td or th - element (as defined by the table model).

        • -
        + unordered set of unique element references attribute such that each of the + + headers-associated elements is a th + element taking part in the same table as the td + or th element (as defined by the table model).

        A th element X is said to be directly targeted by a td or th element Y in the same table if Y's - - headers-associated elements includes - X. A th element A is said to be targeted by a - th or td element B if either A is - directly targeted by B or if there exists an element C that is itself - targeted by the element B and A is directly targeted by - C.

        + data-x="concept-table">table if X is referred to by Y's + headers attribute. + A th element A is said to be targeted by a th or + td element B if either A is directly targeted by + B or if there exists an element C that is itself targeted by the + element B and A is directly targeted by C.

        A th element must not be targeted by itself.

        @@ -52661,11 +52671,8 @@ You cannot submit this form when the field is incorrect.

        The list attribute is used to identify an element that lists predefined options suggested to the user.

        -

        If present, its value must a valid single - element reference attribute such that the - - list-associated element is a - datalist.

        +

        If present, its value must a valid single element reference attribute referring to a datalist.

        @@ -55400,10 +55407,8 @@ interface HTMLOutputElement : HTMLElement {

        The for content attribute allows an explicit relationship to be made between the result of a calculation and the elements that represent the values that went into the calculation or that otherwise influenced the - calculation. The for attribute, if specified, must contain a - string consisting of an unordered set of unique space-separated tokens, none of which - are identical to another token and each of which must have the value of an ID of an element in the same tree.

        + calculation. The for attribute, if specified, must be a + valid unordered set of unique element references.

        The form attribute is used to explicitly associate the output element with its form owner. The HTMLLegendElement : HTMLElement {

        If a listed form-associated element has a form attribute specified, then that attribute's value must be - the ID of a form element in the element's - tree.

        + a valid single element reference attribute + referring to a form + element.

        @@ -87035,9 +87041,8 @@ dictionary DragEventInit : MouseEventInit {

        If specified, the popovertarget attribute value must - be the ID of an element with a popover attribute in the same tree as the button with the single element reference attribute + referring to an element with the popovertarget attribute.

        The popovertargetaction attribute is an From c99b613ab7c6acff8915290efa77da09e648456e Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Fri, 7 Mar 2025 00:20:19 +0000 Subject: [PATCH 15/20] Update itemref attribute --- source | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/source b/source index 54e162ad8ce..045143fd5b2 100644 --- a/source +++ b/source @@ -76172,10 +76172,8 @@ Demos: specified, to give a list of additional elements to crawl to find the name-value pairs of the item.

        -

        The itemref attribute, if specified, must have a value that - is an unordered set of unique space-separated tokens none of which are - identical to another token and consisting of IDs of - elements in the same tree.

        +

        The itemref attribute, if specified, must be a valid + unordered set of unique element references attribute.

        The itemref attribute must not be specified on elements that do not have an itemscope attribute specified.

        @@ -76498,12 +76496,9 @@ Demos:
      3. Add the child elements of root, if any, to pending.

      4. -
      5. If root has an itemref attribute, split the value of that itemref attribute on ASCII whitespace. For each resulting - token ID, if there is an element in the tree of root with the - ID ID, then add the first such element to - pending.

      6. +
      7. If root has an itemref attribute, set + pending to the + itemref-associated elements.

      8. While pending is not empty:

        From 89f72a40db5e5af1ba9aa649a6b19e7bc6deb7f0 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Fri, 7 Mar 2025 22:40:58 +0000 Subject: [PATCH 16/20] Update attributes table --- source | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source b/source index 045143fd5b2..1d4b0d4d40a 100644 --- a/source +++ b/source @@ -143331,7 +143331,7 @@ interface External { for output Specifies controls from which the output was calculated - Unordered set of unique space-separated tokens consisting of IDs* + Unordered set of unique element references form button; @@ -143381,7 +143381,7 @@ interface External { td; th The header cells for this cell - Unordered set of unique space-separated tokens consisting of IDs* + Unordered set of unique element references* height canvas; @@ -143499,7 +143499,7 @@ interface External { itemref HTML elements Referenced elements - Unordered set of unique space-separated tokens consisting of IDs* + Unordered set of unique element references itemscope HTML elements From f8ad4a790cb3273e29621f3c2af28f1341eed7cf Mon Sep 17 00:00:00 2001 From: Alice Boxhall <95208+alice@users.noreply.github.com> Date: Fri, 14 Mar 2025 16:19:40 +1100 Subject: [PATCH 17/20] Add notes an examples in the Element reference attributes section, and make some tweaks in the Reflection section --- source | 66 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/source b/source index 1d4b0d4d40a..a84c9b68644 100644 --- a/source +++ b/source @@ -5252,6 +5252,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
      9. Otherwise, let candidate be null.

      +

      An element will only have an + explicitly-set attr-element if it has + an IDL attribute with a type derived from Element which + reflects attr.

    2. @@ -5276,12 +5280,39 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    +
    +

    A label element can use the for attribute to + create an association with an input element:

    + +
    <label for="name">Name:</label>
    +<input id="name">
    + +

    In this example, the input element is the + for-associated element for the label + element.

    + +

    An element with a shadow root may use a reference target to allow + attr-association to be created with an element inside of its shadow root: + +

    <label for="name">Name:</label>
    +<fancy-input id="name">
    + <template shadowrootmode="closed"
    +           shadowrootreferencetarget="real-input">
    +  <input id="real-input">
    + </template>
    +</fancy-input>
    +
    + +

    In this second example, the input inside of the shadow root is the + for-associated element.

    +
    +
    Sets of element references

    A set of element references attribute represents a set of references to elements. When specified as a content attribute, a set of element - references consists of a set of space-separated tokens, each of which should + references consists of a set of space-separated tokens, each of which shoulds completely match the ID of another element in the document.

    An unordered set of unique element @@ -5326,6 +5357,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute + + +

    An element will only have + explicitly-set attr-elements if it + has an IDL attribute with type FrozenArray<T>?, where T is either + Element or an interface that inherits from Element, which + reflects attr.

  • @@ -5347,12 +5386,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
    • candidate's root is the same as element's - root;

    • + root; and

      -
    • candidate's ID is id; - and

    • - -
    • candidate implements T.

    • +
    • candidate's ID is id.

      +

    If no such element exists, then continue.

    @@ -8709,10 +8746,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute -

    If a reflected IDL attribute has the type T?, - where T is either Element or an interface that inherits from - Element, then with attr being the reflected content attribute - name:

    +

    If a reflected IDL attribute has the type Element, then with + attr being the reflected content attribute name:

    • Its reflected target has an @@ -8731,7 +8766,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    • Return the result of retargeting candidate against this.

    • -
    • +
    • The setter steps are:

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

      If a reflected IDL attribute has the type FrozenArray<T>?, where T is either - Element or an interface that inherits from Element, then with - attr being the reflected content attribute name:

      + data-x="">FrozenArray<Element>?
      , then with attr being the reflected + content attribute name:

      • Its reflected target has an explicitly set @@ -8792,7 +8826,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute elements, which is a list of elements. It is initially « ».

      • Its reflected target has a cached attr-associated - elements object, which is a FrozenArray<T>?. It is + elements object, which is a FrozenArray<Element>?. It is initially null.

      • @@ -8821,7 +8855,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
      • Let elementsAsFrozenArray be retargetedElements, converted to a FrozenArray<T>?.

      • + data-x="">FrozenArray<Element>?
        .

      • Set this's cached attr-associated elements to retargetedElements.

      • From afbcf0141fd03792aab776c46cfee9a9b7047821 Mon Sep 17 00:00:00 2001 From: Alice Boxhall <95208+alice@users.noreply.github.com> Date: Fri, 14 Mar 2025 17:41:48 +1100 Subject: [PATCH 18/20] A few more minor tweaks --- source | 50 +++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/source b/source index a84c9b68644..a5060ec0c3c 100644 --- a/source +++ b/source @@ -46539,6 +46539,11 @@ interface HTMLLabelElement : HTMLElement {
        +

        The for attribute may + be specified to indicate a form control with which the caption is to be associated. If the + attribute is specified, the attribute's value must be the a valid single element + reference attribute.

        +

        To determine a label element's labeled control, run these steps:

          @@ -46573,21 +46578,6 @@ interface HTMLLabelElement : HTMLElement {
        1. Return null.

        -
        - -

        The for attribute may - be specified to indicate a form control with which the caption is to be associated. If the - attribute is specified, the attribute's value must be the ID of a - labelable element in the same tree as the - label element.

        - -
        - -

        If the for attribute is not specified, but the - label element has a labelable element descendant, - then the first such descendant in tree order is the label element's - labeled control.

        -

        The label element's exact default presentation and behavior, in particular what its activation behavior might be, if anything, should match the platform's label behavior. The activation behavior of a label element for events targeted @@ -52711,10 +52701,12 @@ You cannot submit this form when the field is incorrect.

        The suggestions source element is the list-associated element, if that element - is a datalist element. If the - list-associated element is null or is not a datalist element, then there is - no suggestions source element.

        + data-x="get the attr-associated element">list-associated + element, if that element is a datalist element. If the + + list-associated element is null or is not a + datalist element, then there is no suggestions + source element.

        If there is a suggestions source element, then, when the user agent is allowing the user to edit the input element's


        The list IDL - attribute must reflect the list content attribute.

        + attribute must return the current suggestions source + element, if any, retargeted against this, + or null otherwise.


        @@ -56505,10 +56499,11 @@ interface HTMLLegendElement : HTMLElement { form owner of that form-associated element.

        When a listed form-associated element has a - form attribute and the reference target of the - shadow root of any shadow host element in the same flat - tree changes, then the user agent must reset the form owner of that - form-associated element.

        + form attribute and the reference target of any + shadow root of any shadow-including inclusive ancestor of the + form-associated + element for the form-associated element changes, then the user agent must + reset the form owner of that form-associated element.

        When a listed form-associated element has a form attribute and an element with an HTMLLegendElement : HTMLElement { data-x="attr-fae-form">form content attribute, and is connected, then:

          -
        1. Let candidate be the result of resolving the reference target on the first - element in element's tree, in tree order, to have an ID that is identical to element's form content attribute's value.

        2. +
        3. Let candidate be the + form-associated element.

        4. From e3503689e23e11be77c53d8b18eb80df1aa4dbd7 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Sat, 15 Mar 2025 01:59:58 +0000 Subject: [PATCH 19/20] Remove stray edit --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index a5060ec0c3c..11356c972ea 100644 --- a/source +++ b/source @@ -5312,7 +5312,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

          A set of element references attribute represents a set of references to elements. When specified as a content attribute, a set of element - references consists of a set of space-separated tokens, each of which shoulds + references consists of a set of space-separated tokens, each of which should completely match the ID of another element in the document.

          An unordered set of unique element From b179371cabdb416e5869c238e89ef80f3a26e5c7 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Sat, 15 Mar 2025 02:31:12 +0000 Subject: [PATCH 20/20] Simplify cases where 'reset the form owner' has to be called --- source | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/source b/source index 11356c972ea..65286138055 100644 --- a/source +++ b/source @@ -56494,22 +56494,9 @@ interface HTMLLegendElement : HTMLElement { agent must reset the form owner of that element.

          When a listed form-associated element has a - form attribute and the ID of - any of the elements in the tree changes, then the user agent must reset the - form owner of that form-associated element.

          - -

          When a listed form-associated element has a - form attribute and the reference target of any - shadow root of any shadow-including inclusive ancestor of the + form attribute and that element's form-associated - element for the form-associated element changes, then the user agent must - reset the form owner of that form-associated element.

          - -

          When a listed form-associated element has a - form attribute and an element with an ID is inserted - into or removed from the - Document, then the user agent must reset the form owner of that + element changes, then the user agent must reset the form owner of the form-associated element.

          The form owner is also reset by the HTML Standard's