From cbad36ea2e064572a345db8cf40e7505e0a21661 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Tue, 16 Jan 2024 11:20:14 -0800 Subject: [PATCH 1/8] Just assert that a cloned node is not a shadow host --- dom.bs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dom.bs b/dom.bs index 182f246d..ac4626ea 100644 --- a/dom.bs +++ b/dom.bs @@ -4502,6 +4502,8 @@ dom-Range-extractContents, dom-Range-cloneContents --> clonable is true:
    +
  1. Assert: copy is not a shadow host. +

  2. Run attach a shadow root with copy, node's shadow root's mode, true, node's shadow root's delegates focus, and node's From 3b3e70a8a9023bcf405a9caeeafe4307a404a7ba Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Tue, 16 Jan 2024 13:50:46 -0800 Subject: [PATCH 2/8] Enforce same parameters for attachShadow on declarative shadow root Per the discussion at https://github.com/whatwg/dom/issues/1235, this PR changes the behavior when calling `attachShadow()` on a node with an existing declarative shadow root. Now, if the parameters do not match between the arguments to `attachShadow()` and the existing root, throw an exception. Prior behavior was to silently return the declarative root as-is, with mismatched parameters. --- dom.bs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dom.bs b/dom.bs index ac4626ea..fcd0a638 100644 --- a/dom.bs +++ b/dom.bs @@ -6960,8 +6960,14 @@ a boolean delegatesFocus, and a boolean slotAssignment:

    If element is a shadow host, then:

      -
    1. If element's shadow root's declarative - is false, then throw an "{{NotSupportedError!!exception}}" {{DOMException}}. +

    2. Let existing root be element's shadow root. + +

    3. If existing root's declarative + is false, or existing root's mode does not match + mode, or existing root's delegates focus does + not match delegatesFocus, or existing root's + slot assignment does not match slotAssignment, + then throw a "{{NotSupportedError!!exception}}" {{DOMException}}.

    4. Otherwise: From 13198db61ad17216f83fabf6b668e857771c485c Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Fri, 26 Jan 2024 17:33:52 -0800 Subject: [PATCH 3/8] Address comments --- dom.bs | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/dom.bs b/dom.bs index fcd0a638..230d7ffd 100644 --- a/dom.bs +++ b/dom.bs @@ -4502,7 +4502,7 @@ dom-Range-extractContents, dom-Range-cloneContents --> clonable is true:

        -
      1. Assert: copy is not a shadow host. +

      2. Assert: copy is not a shadow host.

      3. Run attach a shadow root with copy, node's shadow root's mode, true, node's @@ -6960,14 +6960,31 @@ a boolean delegatesFocus, and a boolean slotAssignment:

        If element is a shadow host, then:

          -
        1. Let existing root be element's shadow root. - -

        2. If existing root's declarative - is false, or existing root's mode does not match - mode, or existing root's delegates focus does - not match delegatesFocus, or existing root's - slot assignment does not match slotAssignment, - then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. +

        3. Let currentShadowRoot be element's + shadow root. + +

        4. If one of the following is true: + +

            +
          • currentShadowRoot's declarative is false, + +

          • currentShadowRoot's mode does not match + mode, + +

          • currentShadowRoot's delegates focus does + not match delegatesFocus, + +

          • currentShadowRoot's slot assignment does + not match slotAssignment, + +

          • currentShadowRoot's clonable does + not match clonable, +

          + +

          then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. + +

          Any new parameters added to attach a shadow root should be + added to the list of tests above.

        5. Otherwise: From 1c63c4fb7aad6f865352cd65972336b86e53b4ee Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Mon, 29 Jan 2024 11:05:54 -0800 Subject: [PATCH 4/8] Address comments --- dom.bs | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/dom.bs b/dom.bs index 230d7ffd..bd9766a9 100644 --- a/dom.bs +++ b/dom.bs @@ -6933,6 +6933,10 @@ are: element element, a string mode, a boolean clonable, a boolean delegatesFocus, and a boolean slotAssignment: + +

          1. If element's namespace is not the HTML namespace, then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. @@ -6963,28 +6967,26 @@ a boolean delegatesFocus, and a boolean slotAssignment:

          2. Let currentShadowRoot be element's shadow root. -

          3. If one of the following is true: - -

              -
            • currentShadowRoot's declarative is false, +

            • +

              If one of the following is true: -

            • currentShadowRoot's mode does not match - mode, +

                +
              • currentShadowRoot's declarative is false, -

              • currentShadowRoot's delegates focus does - not match delegatesFocus, +

              • currentShadowRoot's mode does not match + mode, -

              • currentShadowRoot's slot assignment does - not match slotAssignment, +

              • currentShadowRoot's delegates focus does + not match delegatesFocus, -

              • currentShadowRoot's clonable does - not match clonable, -

              +
            • currentShadowRoot's slot assignment does + not match slotAssignment, or -

              then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. +

            • currentShadowRoot's clonable does + not match clonable, +

            -

            Any new parameters added to attach a shadow root should be - added to the list of tests above. +

            then throw a "{{NotSupportedError!!exception}}" {{DOMException}}.

          4. Otherwise: From 149f31c0a68585d74ba44e279d1fbb1db2f87ab9 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Thu, 1 Feb 2024 18:24:02 -0800 Subject: [PATCH 5/8] Fix slotAssignment to be a string --- dom.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom.bs b/dom.bs index bd9766a9..380335a3 100644 --- a/dom.bs +++ b/dom.bs @@ -6931,7 +6931,7 @@ are:

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

            1. If element's namespace is not the HTML namespace, then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. @@ -6974,16 +6970,7 @@ a boolean delegatesFocus, and a string slotAssignment:

            2. currentShadowRoot's declarative is false,

            3. currentShadowRoot's mode does not match - mode, - -

            4. currentShadowRoot's delegates focus does - not match delegatesFocus, - -

            5. currentShadowRoot's slot assignment does - not match slotAssignment, or - -

            6. currentShadowRoot's clonable does - not match clonable, + mode, or

              then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. From 16dcb39d3d31974c7aef6f0d7552ab0246d709bf Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Wed, 14 Feb 2024 16:54:05 -0800 Subject: [PATCH 7/8] Address comments --- dom.bs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dom.bs b/dom.bs index 21b58d3a..fcac74af 100644 --- a/dom.bs +++ b/dom.bs @@ -6967,10 +6967,10 @@ a boolean delegatesFocus, and a string slotAssignment:

              If one of the following is true:

                -
              • currentShadowRoot's declarative is false, +

              • currentShadowRoot's declarative is false

              • currentShadowRoot's mode does not match - mode, or + mode

              then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. @@ -6979,11 +6979,10 @@ a boolean delegatesFocus, and a string slotAssignment:

              Otherwise:

                -
              1. Remove all of element's shadow root's +

              2. Remove all of currentShadowRoot's children, in tree order. -

              3. Set element's shadow root's - declarative to false. +

              4. Set currentShadowRoot's declarative to false.

              5. Return.

              From 30a0f3bc74968d499ff2e2b180d6f1c6eb627f13 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Thu, 15 Feb 2024 04:46:07 -0800 Subject: [PATCH 8/8] nits --- dom.bs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/dom.bs b/dom.bs index fcac74af..80a7c85b 100644 --- a/dom.bs +++ b/dom.bs @@ -6960,17 +6960,15 @@ a boolean delegatesFocus, and a string slotAssignment:

              If element is a shadow host, then:

                -
              1. Let currentShadowRoot be element's - shadow root. +

              2. Let currentShadowRoot be element's shadow root.

              3. -

                If one of the following is true: +

                If any of the following are true:

                  -
                • currentShadowRoot's declarative is false +

                • currentShadowRoot's declarative is false; or -

                • currentShadowRoot's mode does not match - mode +

                • currentShadowRoot's mode is not mode,

                then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. @@ -6979,16 +6977,13 @@ a boolean delegatesFocus, and a string slotAssignment:

                Otherwise:

                  -
                1. Remove all of currentShadowRoot's - children, in tree order. +

                2. Remove all of currentShadowRoot's children, in + tree order.

                3. Set currentShadowRoot's declarative to false.

                4. Return.

                - -

                This means that if multiple declarative shadow roots are contained within a single - shadow host, only the last one will remain.

            7. Let shadow be a new shadow root whose node document