diff --git a/source b/source index 820de145209..7de9a817904 100644 --- a/source +++ b/source @@ -3255,7 +3255,14 @@ 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, serializable, custom element registry, and keep custom element registry null.
  • +
  • The shadow root concept, and its + delegates focus, + available to element internals, + clonable, + serializable, + custom element registry, + keep custom element registry null, and + reference target.
  • The shadow host concept
  • HTMLCollection interface, its length attribute, and its @@ -5296,6 +5303,277 @@ 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 as their target(s). 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 are:

    + +
      +
    1. If element is not a shadow host, or element's + shadow root's reference target is null, then return + element.

      +
    2. + +
    3. Let referenceTargetValue be the value of element's shadow + root's reference target.

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

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

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

    10. +
    +
    + +
    Single-element references
    + +

    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 as its + target if Y is the resolved + attr target element for X.

    +
    + +
    +

    The rules to get the resolved + attr target element for a single-element reference attribute + attr and element element are:

    + +
      +
    1. Let unresolvedTarget be the + unresolved attr target + element.

    2. + +
    3. If unresolvedTarget is null, return null.

    4. + +
    5. Return the result of resolving the reference + target on unresolvedTarget.

    6. +
    +
    + +
    +

    The rules to get the unresolved + attr target element for a single-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 + unresolvedTarget be element's + explicitly-set attr-element.

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

      4. +
      + +

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

      +
    4. + +
    5. +

      Otherwise:

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

      2. + +
      3. Let unresolvedTarget be the first element in element's + tree, in tree order whose ID is + value. If no such element exists, let unresolvedTarget be null.

        +
      4. +
      +
    6. + +
    7. Return unresolvedTarget.

    8. +
    +
    + +
    +

    A label element can use the for attribute to + refer to an input element as its target:

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

    In this example, the input element is the resolved + for target element for the label + element.

    + +

    An element with a shadow root may use a reference target to allow + for to refer to 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 resolved + for target 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 + 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.

    + +

    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 + as a target if Y is one of the + resolved attr target + elements for X.

    +
    + +
    +

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

    + +
      +
    1. Let unresolvedTargets be the + unresolved attr target + elements.

    2. + +
    3. Let resolvedTargets be « ».

    4. + +
    5. +

      For each unresolvedTarget of + unresolvedTargets: +

      + +
        +
      1. Let resolvedTarget be the result of + resolving the reference target on + unresolvedTarget.

      2. + +
      3. If resolvedTarget is not null, then append resolvedTarget to + resolvedTargets.

      4. +
      +
    6. + +
    7. Return resolvedTargets.

    8. +
    +
    + +
    +

    The rules to get the unresolved attrtarget 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. + +
    3. Let unresolvedTargets be « ».

    4. + +
    5. +

      If element has an explicitly set attr-elements:

      + +
        +
      1. +

        For each attrElement of + 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. Append attrElement to + unresolvedTargets.

        4. +
        +
      2. +
      + +

      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.

      +
    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 unresolvedTarget be the first element, in tree order, that + meets the following criteria:

          + +
            +
          • unresolvedTarget's root is the same as element's + root; and

          • + +
          • unresolvedTarget's ID is + id.

          • +
          + +

          If no such element exists, then continue.

          +
        2. + +
        3. Append unresolvedTarget to + unresolvedTargets.

        4. +
        +
      5. +
      +
    8. + +
    9. Return unresolvedTargets.

    10. +
    +
    + +

    Numbers

    @@ -8852,69 +9130,18 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute DOMTokenList. -->
    -

    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:

    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 popovertarget attribute.

    + be a valid single-element reference attribute + referring to an element with the popover attribute.

    The popovertargetaction attribute is an enumerated attribute with the following keywords and states:

    @@ -91788,9 +91968,9 @@ dictionary DragEventInit : MouseEventInit {
  • If node has a form owner and node is a submit button, then return null.

  • -
  • Let popoverElement be the result of running node's get the popovertarget-associated - element.

  • +
  • Let popoverElement be node's resolved popovertarget + target element.

  • If popoverElement is null, then return null.

  • @@ -140644,6 +140824,10 @@ document.body.appendChild(text); data-x="attr-template-shadowrootdelegatesfocus">shadowrootdelegatesfocus attribute; otherwise false.

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

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

  • @@ -140660,8 +140844,8 @@ document.body.appendChild(text);
  • Attach a shadow root with declarativeShadowHostElement, mode, clonable, - serializable, delegatesFocus, "named", and - registry.

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

    If an exception is thrown, then catch it and:

    @@ -144477,6 +144661,19 @@ document.body.appendChild(text);
  • If shouldAppendRegistryAttribute is true, then append " shadowrootcustomelementregistry=""".

  • +
  • +

    If shadow's reference target is non-null:

    + +
      +
    1. Append " + shadowrootreferencetarget="".

    2. + +
    3. Append shadow's reference target.

    4. + +
    5. Append """.

    6. +
    +
  • +
  • Append ">".

  • Append the value of running the HTML fragment serialization algorithm with @@ -153376,7 +153573,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; @@ -153426,7 +153623,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* headingoffset HTML elements @@ -153554,7 +153751,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 @@ -153912,6 +154109,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