From e06f9031447d5afbc1d7469432a0df54de23a60d Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Tue, 4 Feb 2025 20:13:45 +0000 Subject: [PATCH 01/10] Add reference target to shadow root --- dom.bs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/dom.bs b/dom.bs index 8645c1ff4..12e58fb52 100644 --- a/dom.bs +++ b/dom.bs @@ -4587,8 +4587,9 @@ and an optional document docume
  • Attach a shadow root with copy, node's shadow root's mode, true, node's shadow root's serializable, node's - shadow root's delegates focus, and node's - shadow root's slot assignment. + shadow root's delegates focus, node's + shadow root's slot assignment, and node's + shadow root's reference target.

  • Set copy's shadow root's declarative to node's shadow root's declarative. @@ -6057,6 +6058,7 @@ interface ShadowRoot : DocumentFragment { readonly attribute boolean clonable; readonly attribute boolean serializable; readonly attribute Element host; + attribute DOMString? referenceTarget; attribute EventHandler onslotchange; }; @@ -6092,6 +6094,9 @@ It is initially set to false.

    Shadow roots have an associated serializable (a boolean). It is initially set to false.

    +

    Shadow roots have an associated reference target. +It is initially set to null.

    +

    A shadow root's get the parent algorithm, given an event, returns null if event's composed flag is unset and shadow root is the root of event's path's first struct's @@ -6116,6 +6121,12 @@ null if event's composed flag is unset and shadow roo

    The host getter steps are to return this's host. +

    The referenceTarget getter steps are to return +this's reference target. + +

    The {{ShadowRoot/referenceTarget}} setter steps are to set +this's reference target to the given value. +

    The onslotchange attribute is an event handler IDL attribute for the onslotchange event handler, whose @@ -6246,6 +6257,7 @@ dictionary ShadowRootInit { SlotAssignmentMode slotAssignment = "named"; boolean clonable = false; boolean serializable = false; + DOMString? referenceTarget = null; }; @@ -7099,8 +7111,9 @@ are:

  • Run attach a shadow root with this, init["{{ShadowRootInit/mode}}"], init["{{ShadowRootInit/clonable}}"], init["{{ShadowRootInit/serializable}}"], - init["{{ShadowRootInit/delegatesFocus}}"], and - init["{{ShadowRootInit/slotAssignment}}"]. + init["{{ShadowRootInit/delegatesFocus}}"], + init["{{ShadowRootInit/slotAssignment}}"], and + init["{{ShadowRootInit/referenceTarget}}"].

  • Return this's shadow root. @@ -7109,8 +7122,8 @@ are:

    To attach a shadow root, given an element element, a string mode, a boolean clonable, -a boolean serializable, a boolean delegatesFocus, and a string -slotAssignment: +a boolean serializable, a boolean delegatesFocus, a string +slotAssignment, and null or a string referenceTarget:

    1. If element's namespace is not the HTML namespace, @@ -7178,6 +7191,8 @@ a boolean serializable, a boolean delegatesFocus, and a st

    2. Set shadow's slot assignment to slotAssignment. +

    3. Set shadow's reference target to referenceTarget. +

    4. Set shadow's declarative to false.

    5. Set shadow's clonable to clonable. From 496ccae036e0c2190546790156634bc3ac9c614d Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Tue, 6 May 2025 23:15:40 +0000 Subject: [PATCH 02/10] Make order consistent with other ShadowRoot properties --- dom.bs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dom.bs b/dom.bs index 4759dc811..80905b01b 100644 --- a/dom.bs +++ b/dom.bs @@ -6384,6 +6384,12 @@ false.

      Shadow roots have an associated clonable (a boolean). It is initially set to false.

      +

      Shadow roots have an associated serializable (a boolean). +It is initially set to false.

      + +

      Shadow roots have an associated reference target. +It is initially set to null.

      +

      Shadow roots have an associated custom element registry (null or a {{CustomElementRegistry}} object). It is initially null.

      @@ -6394,12 +6400,6 @@ It is initially set to false.

      matters for as long as the shadow root's custom element registry is null. -

      Shadow roots have an associated serializable (a boolean). -It is initially set to false.

      - -

      Shadow roots have an associated reference target. -It is initially set to null.

      -

      A shadow root's get the parent algorithm, given an event, returns @@ -6562,8 +6562,8 @@ dictionary ShadowRootInit { SlotAssignmentMode slotAssignment = "named"; boolean clonable = false; boolean serializable = false; - CustomElementRegistry customElementRegistry; DOMString? referenceTarget = null; + CustomElementRegistry customElementRegistry; }; @@ -7550,14 +7550,14 @@ a boolean serializable, a boolean delegatesFocus, a string

    6. Set shadow's slot assignment to slotAssignment. -

    7. Set shadow's reference target to referenceTarget. -

    8. Set shadow's declarative to false.

    9. Set shadow's clonable to clonable.

    10. Set shadow's serializable to serializable. +

    11. Set shadow's reference target to referenceTarget. +

    12. Set shadow's custom element registry to registry. From 64676d640f2427741f4d8371d1f47e01a3559be1 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Tue, 6 May 2025 23:21:59 +0000 Subject: [PATCH 03/10] Add type declaration for ShadowRoot reference target --- dom.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dom.bs b/dom.bs index 80905b01b..9014a5e34 100644 --- a/dom.bs +++ b/dom.bs @@ -6387,8 +6387,8 @@ It is initially set to false.

      Shadow roots have an associated serializable (a boolean). It is initially set to false.

      -

      Shadow roots have an associated reference target. -It is initially set to null.

      +

      Shadow roots have an associated reference target +(null or a string). It is initially set to null.

      Shadow roots have an associated custom element registry (null or a {{CustomElementRegistry}} object). It is initially null.

      From ec59294551f2bad7b081b0c6a0bffc7d22cbc864 Mon Sep 17 00:00:00 2001 From: Alice Boxhall <95208+alice@users.noreply.github.com> Date: Tue, 3 Jun 2025 11:07:05 +0200 Subject: [PATCH 04/10] Propagate events into the event's source's tree where appropriate. - Add the concept of a "source" for an Event. - Modify shadow root's "get the parent" algorithm such that events propagate into the event's source's tree where appropriate. --- dom.bs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/dom.bs b/dom.bs index 491e26911..ace810a53 100644 --- a/dom.bs +++ b/dom.bs @@ -401,6 +401,9 @@ signaling that something has occurred, e.g., that an image has completed downloa

      Other specifications use relatedTarget to define a relatedTarget attribute. [[UIEVENTS]] +

      An event has an associated source (a +potential event target). Unless stated otherwise it is null. +

      An event has an associated touch target list (a list of zero or more potential event targets). Unless stated otherwise it is the empty list. @@ -6398,10 +6401,22 @@ is null.


      A shadow root's get the parent algorithm, given an event, returns -null if event's composed flag is unset and shadow root is the -root of event's path's first struct's -invocation target; otherwise shadow root's -host. +the result of the following steps:

      + +
        +
      1. If event’s composed flag is set, return shadow root’s + host.

      2. +
      3. Let target be event’s path's first struct's + invocation target.

      4. +
      5. Let source be event's source.

      6. +
      7. If shadow root is not the root of target, and either + source is null or shadow root is not the root of + source, return shadow root's host.

      8. +
      9. If source is not null, and source's root is a + shadow-including ancestor of shadow root, return the result of + retargeting target against source.

      10. +
      11. Return null.

      12. +

      From 9a82ae0beb9d485729f277bbce076015b19b25cb Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Thu, 29 Jan 2026 15:10:34 -0800 Subject: [PATCH 05/10] Add missing definition for ShadowRoot.referenceTarget getter/setter --- dom.bs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dom.bs b/dom.bs index 990bdc298..bbb24bf43 100644 --- a/dom.bs +++ b/dom.bs @@ -6633,6 +6633,10 @@ null if event's composed flag is unset and shadow roo

      The host getter steps are to return this's host. +

      The referenceTarget getter steps are to return +this's reference target. The {{ShadowRoot/referenceTarget}} setter +steps are to set this's reference target to the given value. +


      The onslotchange attribute is an From c6fbd2cb71e51bf966356aea213f551b68c275b8 Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Tue, 26 May 2026 15:46:03 -0700 Subject: [PATCH 06/10] Misc style/formatting/typo fixups --- dom.bs | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/dom.bs b/dom.bs index cf76cbf45..2e96104e3 100644 --- a/dom.bs +++ b/dom.bs @@ -6610,23 +6610,31 @@ is null.


      -

      A shadow root's get the parent algorithm, given an event, returns -the result of the following steps:

      - -
        -
      1. If event’s composed flag is set, return shadow root’s - host.

      2. -
      3. Let target be event’s path's first struct's - invocation target.

      4. -
      5. Let source be event's source.

      6. -
      7. If shadow root is not the root of target, and either - source is null or shadow root is not the root of - source, return shadow root's host.

      8. +
        +

        A shadow root shadowRoot's get the parent algorithm, given an +event, returns the result of the following steps: + +

          +
        1. If event's composed flag is set, then return shadowRoot's + host. + +

        2. Let target be event's path's first struct's + invocation target. + +

        3. Let source be event's source. + +

        4. If shadowRoot is not the root of target, and either + source is null or shadowRoot is not the root of + source, then return shadowRoot's host. +

        5. If source is not null, and source's root is a - shadow-including ancestor of shadow root, return the result of - retargeting target against source.

        6. -
        7. Return null.

        8. + shadow-including ancestor of shadowRoot, then return the result of + retargeting target against source. + +
        9. Return null.

        +

        @@ -6649,7 +6657,9 @@ the result of the following steps:

        this's host.

        The referenceTarget getter steps are to return -this's reference target. The {{ShadowRoot/referenceTarget}} setter +this's reference target. + +

        The {{ShadowRoot/referenceTarget}} setter steps are to set this's reference target to the given value.


        @@ -7763,7 +7773,7 @@ are: init["{{ShadowRootInit/mode}}"], init["{{ShadowRootInit/clonable}}"], init["{{ShadowRootInit/serializable}}"], init["{{ShadowRootInit/delegatesFocus}}"], - init["{{ShadowRootInit/slotAssignment}}"], and + init["{{ShadowRootInit/slotAssignment}}"], init["{{ShadowRootInit/referenceTarget}}"], and registry.
      9. Return this's shadow root. From 6f1bbe2ca0f7281eb71b0b88ef7e30c432b5881c Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Tue, 26 May 2026 15:53:04 -0700 Subject: [PATCH 07/10] Remove one more closing

        --- dom.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom.bs b/dom.bs index 2e96104e3..30bf2ef46 100644 --- a/dom.bs +++ b/dom.bs @@ -6596,7 +6596,7 @@ It is initially set to false.

        It is initially set to false.

        Shadow roots have an associated reference target -(null or a string). It is initially set to null.

        +(null or a string). It is initially set to null.

        Shadow roots have an associated custom element registry (null or a {{CustomElementRegistry}} object). It is initially null.

        From 92aaa5ae5c8ad9ff4aaae7b0ad30a65865b60d7e Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Tue, 2 Jun 2026 10:09:46 -0700 Subject: [PATCH 08/10] Revert changes to shadow root's get the parent --- dom.bs | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/dom.bs b/dom.bs index 30bf2ef46..bb81e6114 100644 --- a/dom.bs +++ b/dom.bs @@ -6610,31 +6610,11 @@ is null.
        -
        -

        A shadow root shadowRoot's get the parent algorithm, given an -event, returns the result of the following steps: - -

          -
        1. If event's composed flag is set, then return shadowRoot's - host. - -

        2. Let target be event's path's first struct's - invocation target. - -

        3. Let source be event's source. - -

        4. If shadowRoot is not the root of target, and either - source is null or shadowRoot is not the root of - source, then return shadowRoot's host. - -

        5. If source is not null, and source's root is a - shadow-including ancestor of shadowRoot, then return the result of - retargeting target against source. - -

        6. Return null. -

        -
        +

        A shadow root's get the parent algorithm, given an event, returns +null if event's composed flag is unset and shadow root is the +root of event's path's first struct's +invocation target; otherwise shadow root's +host.


        From fb3bfb934686b30aa56148821d71eac1e0f51e6f Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Tue, 2 Jun 2026 14:22:07 -0700 Subject: [PATCH 09/10] Remove event source concept --- dom.bs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dom.bs b/dom.bs index bb81e6114..39369686c 100644 --- a/dom.bs +++ b/dom.bs @@ -476,9 +476,6 @@ signaling that something has occurred, e.g., that an image has completed downloa

        Other specifications use relatedTarget to define a relatedTarget attribute. [[UIEVENTS]] -

        An event has an associated source (a -potential event target). Unless stated otherwise it is null. -

        An event has an associated touch target list (a list of zero or more potential event targets). Unless stated otherwise it is the empty list. @@ -1746,7 +1743,8 @@ and an optional legacyOutputDidListenersThrowFlag, run these steps:

        To fire an event named e at target, optionally using an eventConstructor, with a description of how IDL attributes are to be -initialized, and a legacy target override flag, run these steps: +initialized, and a legacy target override flag and an optional relatedTarget, +run these steps:

        1. If eventConstructor is not given, then let eventConstructor be @@ -1757,6 +1755,9 @@ initialized, and a legacy target override flag, run these steps:

        2. Initialize event's {{Event/type}} attribute to e. +

        3. If relatedTarget is given, set event's relatedTarget + to relatedTarget. +

        4. Initialize any other IDL attributes of event as described in the invocation of this algorithm. From c2bfb97b9ee41beb0247283082697655fbfd2e2e Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Mon, 8 Jun 2026 14:56:17 -0700 Subject: [PATCH 10/10] Apply current conventions for optional named parameters to fire an event. Fix grammar. --- dom.bs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dom.bs b/dom.bs index 39369686c..1232ce207 100644 --- a/dom.bs +++ b/dom.bs @@ -1360,15 +1360,15 @@ property of the event being dispatched.

          To dispatch an event to a -target, with an optional legacy target override flag and an optional -legacyOutputDidListenersThrowFlag, run these steps: +target, with an optional legacy target override flag (default false) and an +optional legacyOutputDidListenersThrowFlag, run these steps:

          1. Set event's dispatch flag.

          2. Let targetOverride be target, if legacy target override flag - is not given, and target's associated Document otherwise. + is true, and target's associated Document otherwise. [[!HTML]]

            legacy target override flag is only used by HTML and only when @@ -1743,8 +1743,8 @@ and an optional legacyOutputDidListenersThrowFlag, run these steps:

            To fire an event named e at target, optionally using an eventConstructor, with a description of how IDL attributes are to be -initialized, and a legacy target override flag and an optional relatedTarget, -run these steps: +initialized, an optional boolean legacy target override flag (default false), and an +optional {{EventTarget}} relatedTarget:

            1. If eventConstructor is not given, then let eventConstructor be @@ -1755,8 +1755,8 @@ run these steps:

            2. Initialize event's {{Event/type}} attribute to e. -

            3. If relatedTarget is given, set event's relatedTarget - to relatedTarget. +

            4. If relatedTarget is given, then set event's relatedTarget to relatedTarget.

            5. Initialize any other IDL attributes of event as described in the invocation of this @@ -1764,8 +1764,8 @@ run these steps:

              This also allows for the {{Event/isTrusted}} attribute to be set to false. -

            6. Return the result of dispatching event at target, with - legacy target override flag set if set. +

            7. Return the result of dispatching event at target with + legacy target override flag.