From 351e0e94c36866d8d4465c8dd7d3b5b3fbe96b8c 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] Begin work on specifying how referenceTarget affects ID lookups --- source | 154 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 98 insertions(+), 56 deletions(-) diff --git a/source b/source index 213f90acbef..36548332e0b 100644 --- a/source +++ b/source @@ -5128,7 +5128,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute -

Keywords and enumerated attributes

Some attributes, called +

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 +8597,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 +46466,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.