From 450c6bb8ba861c76afcbeeb37f8b1f4511ce9bc4 Mon Sep 17 00:00:00 2001 From: Jayson Chen Date: Mon, 17 Nov 2025 15:03:49 -0800 Subject: [PATCH 1/6] Remove registry restoration on insert but do it in adopt --- dom.bs | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/dom.bs b/dom.bs index d2af7842..b694c8a2 100644 --- a/dom.bs +++ b/dom.bs @@ -2913,12 +2913,7 @@ optional boolean suppressObservers (default f

If inclusiveDescendant is an element:

    -
  1. If inclusiveDescendant's custom element registry is - null, then set inclusiveDescendant's custom element registry to - the result of looking up a custom element registry given - inclusiveDescendant's parent. - -

  2. Otherwise, if inclusiveDescendant's +

  3. If inclusiveDescendant's custom element registry's is scoped is true, append inclusiveDescendant's node document to inclusiveDescendant's custom element registry's @@ -2941,14 +2936,7 @@ optional boolean suppressObservers (default f

    Otherwise, if inclusiveDescendant is a shadow root:

      -
    1. If inclusiveDescendant's custom element registry is - null and inclusiveDescendant's - keep custom element registry null is false, then set - inclusiveDescendant's custom element registry to the result - of looking up a custom element registry given inclusiveDescendant's - host. - -

    2. Otherwise, if inclusiveDescendant's +

    3. If inclusiveDescendant's custom element registry is non-null and inclusiveDescendant's custom element registry's is scoped is true, append @@ -6052,12 +6040,14 @@ these steps:

      1. Set inclusiveDescendant's node document to document. -

      2. If inclusiveDescendant is a shadow root and - inclusiveDescendant's custom element registry - is a global custom element registry, then set inclusiveDescendant's - custom element registry to document's - effective global custom element registry. - +

      3. If inclusiveDescendant is a shadow root: +

          +
        1. If inclusiveDescendant's custom element registry + is a global custom element registry or null, then set inclusiveDescendant's + custom element registry to document's + effective global custom element registry. +
        +
      4. Otherwise, if inclusiveDescendant is an element: @@ -6066,7 +6056,7 @@ these steps: inclusiveDescendant's attribute list to document.

      5. If inclusiveDescendant's custom element registry - is a global custom element registry, then set inclusiveDescendant's + is a global custom element registry or null, then set inclusiveDescendant's custom element registry to document's effective global custom element registry.

      @@ -11074,6 +11064,7 @@ James Graham, James Greene, James M Snell, James Robinson, +Jayson Chen, Jeffrey Yasskin, Jens Lindström, Jeremy Davis, From 7243117e80f1a2a3981a34e5edfac707886c38b9 Mon Sep 17 00:00:00 2001 From: Jayson Chen Date: Tue, 18 Nov 2025 16:01:03 -0800 Subject: [PATCH 2/6] Address comments --- dom.bs | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/dom.bs b/dom.bs index b694c8a2..b71a9354 100644 --- a/dom.bs +++ b/dom.bs @@ -2910,7 +2910,8 @@ optional boolean suppressObservers (default f continue.
    4. -

      If inclusiveDescendant is an element: +

      If inclusiveDescendant is an element and + inclusiveDescendant's custom element registry is not null:

      1. If inclusiveDescendant's @@ -6040,25 +6041,35 @@ these steps:

        1. Set inclusiveDescendant's node document to document. -

        2. If inclusiveDescendant is a shadow root: +

        3. +

          If inclusiveDescendant is a shadow root: +

            -
          1. If inclusiveDescendant's custom element registry - is a global custom element registry or null, then set inclusiveDescendant's - custom element registry to document's - effective global custom element registry. +
          2. If inclusiveDescendant's custom element registry + is null, set inclusiveDescendant's custom element registry + to document's effective global custom element registry. + +

          3. Otherwise, if inclusiveDescendant's + custom element registry is a global custom element registry, + set inclusiveDescendant's custom element registry to + document's effective global custom element registry.

        4. Otherwise, if inclusiveDescendant is an element:

            -
          1. Set the node document of each attribute in - inclusiveDescendant's attribute list to document. +

          2. Set the node document of each attribute in + inclusiveDescendant's attribute list to document. + +

          3. If inclusiveDescendant's custom element registry + is null, set inclusiveDescendant's custom element registry + to document's effective global custom element registry. -

          4. If inclusiveDescendant's custom element registry - is a global custom element registry or null, then set inclusiveDescendant's - custom element registry to document's - effective global custom element registry. +

          5. Otherwise, if inclusiveDescendant's + custom element registry is a global custom element registry, + set inclusiveDescendant's custom element registry to + document's effective global custom element registry.

        From 7c5910363a5cac0cd0ae52cbb3a20d9a6b2115be Mon Sep 17 00:00:00 2001 From: Jayson Chen Date: Wed, 19 Nov 2025 13:40:14 -0800 Subject: [PATCH 3/6] Address comments --- dom.bs | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/dom.bs b/dom.bs index b71a9354..60d43d1a 100644 --- a/dom.bs +++ b/dom.bs @@ -2911,7 +2911,7 @@ optional boolean suppressObservers (default f
      2. If inclusiveDescendant is an element and - inclusiveDescendant's custom element registry is not null: + inclusiveDescendant's custom element registry is non-null:

        1. If inclusiveDescendant's @@ -6045,31 +6045,25 @@ these steps:

          If inclusiveDescendant is a shadow root:

            -
          1. If inclusiveDescendant's custom element registry - is null, set inclusiveDescendant's custom element registry - to document's effective global custom element registry. - -

          2. Otherwise, if inclusiveDescendant's - custom element registry is a global custom element registry, - set inclusiveDescendant's custom element registry to - document's effective global custom element registry. +

          3. if inclusiveDescendant's custom element registry + is null or inclusiveDescendant's custom element registry's + is scoped is false, then set + inclusiveDescendant's custom element registry to + document's effective global custom element registry.

          - +
        2. Otherwise, if inclusiveDescendant is an element:

            -
          1. Set the node document of each attribute in - inclusiveDescendant's attribute list to document. - -

          2. If inclusiveDescendant's custom element registry - is null, set inclusiveDescendant's custom element registry - to document's effective global custom element registry. - -

          3. Otherwise, if inclusiveDescendant's - custom element registry is a global custom element registry, - set inclusiveDescendant's custom element registry to - document's effective global custom element registry. +

          4. Set the node document of each attribute in + inclusiveDescendant's attribute list to document. + +

          5. If inclusiveDescendant's custom element registry + is null or inclusiveDescendant's custom element registry's + is scoped is false, then set + inclusiveDescendant's custom element registry to + document's effective global custom element registry.

        @@ -6538,9 +6532,6 @@ It is initially set to false.

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

        -

        Shadow roots have an associated -keep custom element registry null (a boolean). It is initially false. -

        This can only ever be true in combination with declarative shadow roots. And it only matters for as long as the shadow root's custom element registry is null. From a57411c2d56f248e657e92c86e9e028a6f9d3a10 Mon Sep 17 00:00:00 2001 From: Jayson Chen Date: Mon, 24 Nov 2025 11:59:17 -0800 Subject: [PATCH 4/6] Restore keep custom element registry and check it during adoption --- dom.bs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/dom.bs b/dom.bs index 60d43d1a..9d244326 100644 --- a/dom.bs +++ b/dom.bs @@ -6042,15 +6042,20 @@ these steps:

      3. Set inclusiveDescendant's node document to document.

      4. -

        If inclusiveDescendant is a shadow root: +

        If inclusiveDescendant is a shadow root, and if any of the + following are true: -

          -
        1. if inclusiveDescendant's custom element registry - is null or inclusiveDescendant's custom element registry's - is scoped is false, then set - inclusiveDescendant's custom element registry to - document's effective global custom element registry. -

        + + +

        then set inclusiveDescendant's custom element registry + to document's effective global custom element registry.

      5. Otherwise, if inclusiveDescendant is an element: @@ -6532,6 +6537,9 @@ It is initially set to false.

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

        +

        Shadow roots have an associated +keep custom element registry null (a boolean). It is initially false. +

        This can only ever be true in combination with declarative shadow roots. And it only matters for as long as the shadow root's custom element registry is null. From 25892f2e2454d30ee9045e2b1933c01420643e77 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Tue, 25 Nov 2025 09:10:32 +0100 Subject: [PATCH 5/6] nits --- dom.bs | 47 +++++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/dom.bs b/dom.bs index 9d244326..277f94e1 100644 --- a/dom.bs +++ b/dom.bs @@ -2914,9 +2914,9 @@ optional boolean suppressObservers (default f inclusiveDescendant's custom element registry is non-null:

          -
        1. If inclusiveDescendant's - custom element registry's is scoped is - true, append inclusiveDescendant's node document to +

        2. If inclusiveDescendant's custom element registry's + is scoped is true, then append + inclusiveDescendant's node document to inclusiveDescendant's custom element registry's scoped document set. @@ -2933,18 +2933,13 @@ optional boolean suppressObservers (default f upgrade an element algorithm.

        -
      6. -

        Otherwise, if inclusiveDescendant is a shadow root: - -

          -
        1. If inclusiveDescendant's - custom element registry is non-null and - inclusiveDescendant's custom element registry's - is scoped is true, append - inclusiveDescendant's node document to - inclusiveDescendant's custom element registry's - scoped document set. -

        +
      7. Otherwise, if inclusiveDescendant is a shadow root, + inclusiveDescendant's custom element registry is non-null, and + inclusiveDescendant's custom element registry's + is scoped is true, then append + inclusiveDescendant's node document to + inclusiveDescendant's custom element registry's + scoped document set.

    @@ -6042,20 +6037,20 @@ these steps:
  4. Set inclusiveDescendant's node document to document.

  5. -

    If inclusiveDescendant is a shadow root, and if any of the - following are true: +

    If inclusiveDescendant is a shadow root and if any of the following + are true:

    -

    then set inclusiveDescendant's custom element registry - to document's effective global custom element registry. +

    then set inclusiveDescendant's custom element registry to + document's effective global custom element registry.

  6. Otherwise, if inclusiveDescendant is an element: @@ -6064,8 +6059,8 @@ these steps:

  7. Set the node document of each attribute in inclusiveDescendant's attribute list to document. -

  8. If inclusiveDescendant's custom element registry - is null or inclusiveDescendant's custom element registry's +

  9. If inclusiveDescendant's custom element registry is null + or inclusiveDescendant's custom element registry's is scoped is false, then set inclusiveDescendant's custom element registry to document's effective global custom element registry. From 9821f8a5de4dd5f975684783d9ee49a57177b0b8 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Tue, 25 Nov 2025 11:28:37 +0100 Subject: [PATCH 6/6] more nits --- dom.bs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/dom.bs b/dom.bs index 277f94e1..3574b5fd 100644 --- a/dom.bs +++ b/dom.bs @@ -6016,8 +6016,8 @@ algorithm is passed node and oldDocument, as

    -

    To adopt a node into a document, run -these steps: +

    To adopt a node node into a +document document:

    1. Let oldDocument be node's node document. @@ -6030,8 +6030,8 @@ these steps:

      1. -

        For each inclusiveDescendant in node's - shadow-including inclusive descendants: +

        For each inclusiveDescendant of node's + shadow-including inclusive descendants, in shadow-including tree order:

        1. Set inclusiveDescendant's node document to document. @@ -6067,14 +6067,15 @@ these steps:

      -
    2. For each inclusiveDescendant in node's - shadow-including inclusive descendants that is custom, - enqueue a custom element callback reaction with inclusiveDescendant, callback - name "adoptedCallback", and « oldDocument, document ». +

    3. For each inclusiveDescendant of node's + shadow-including inclusive descendants that is custom, in + shadow-including tree order: enqueue a custom element callback reaction with + inclusiveDescendant, callback name "adoptedCallback", and + « oldDocument, document ». -

    4. For each inclusiveDescendant in node's - shadow-including inclusive descendants, in shadow-including tree order, run the +

    5. For each inclusiveDescendant of node's + shadow-including inclusive descendants, in shadow-including tree order: run the adopting steps with inclusiveDescendant and oldDocument.