From ffef2a26943e86a31002156579ae17b378f9daf7 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Tue, 14 Apr 2020 16:08:54 -0700 Subject: [PATCH 01/13] Added "is declarative shadow root" --- dom.bs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dom.bs b/dom.bs index 139d38d59..a7eec0f4b 100644 --- a/dom.bs +++ b/dom.bs @@ -5727,6 +5727,9 @@ or "closed").

Shadow roots have an associated delegates focus. It is initially set to false.

+

Shadow roots have an associated is declarative shadow root. +It is initially set to false.

+

Shadow roots's associated host is never null.

@@ -6751,6 +6754,8 @@ invoked, must run these steps:
  • Set shadow's delegates focus to init's {{ShadowRootInit/delegatesFocus}}. +

  • Set shadow's is declarative shadow root to false. +

  • Set this's shadow root to shadow.

  • Return shadow. @@ -10133,6 +10138,7 @@ Manish Tripathi, Marcos Caceres, Mark Miller, Martijn van der Ven, +Mason Freed, Mats Palmgren, Mounir Lamouri, Michael Stramel, From 0e2223ad27882502541d9fe7b87c78e1d0ec6ef5 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Tue, 14 Apr 2020 16:29:22 -0700 Subject: [PATCH 02/13] Added existing shadow root support --- dom.bs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dom.bs b/dom.bs index a7eec0f4b..0eb702f46 100644 --- a/dom.bs +++ b/dom.bs @@ -6744,9 +6744,11 @@ invoked, must run these steps:

  • -
  • If this is a shadow host, then throw an +

  • If this is a shadow host whose shadow root's is declarative shadow root property is false, then throw an "{{NotSupportedError!!exception}}" {{DOMException}}. +

  • If this is a shadow host whose shadow root's is declarative shadow root property is true, then remove all of shadow root's children, in tree order. Return this's shadow root. +

  • Let shadow be a new shadow root whose node document is this's node document, host is this, and mode is init's {{ShadowRootInit/mode}}. @@ -6754,7 +6756,7 @@ invoked, must run these steps:

  • Set shadow's delegates focus to init's {{ShadowRootInit/delegatesFocus}}. -

  • Set shadow's is declarative shadow root to false. +

  • Set shadow's is declarative shadow root property to false.

  • Set this's shadow root to shadow. From 23ff7fb5d149139bbfb5ce5cf5b093cb00f925c5 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Wed, 15 Apr 2020 17:51:59 -0700 Subject: [PATCH 03/13] Add getInnerHTML() --- dom.bs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dom.bs b/dom.bs index 0eb702f46..69cace66f 100644 --- a/dom.bs +++ b/dom.bs @@ -5867,6 +5867,8 @@ interface Element : Node { HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); HTMLCollection getElementsByClassName(DOMString classNames); + DOMString getInnerHTML(GetInnerHTMLOptions options); + [CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // historical void insertAdjacentText(DOMString where, DOMString data); // historical }; @@ -5875,6 +5877,10 @@ dictionary ShadowRootInit { required ShadowRootMode mode; boolean delegatesFocus = false; }; + +dictionary GetInnerHTMLOptions { + boolean includeShadowRoots = true; +};

    {{Element}} nodes are simply known as @@ -6882,9 +6888,14 @@ for this.

    Throw a "{{SyntaxError!!exception}}" {{DOMException}}. +

    The +getInnerHTML(options) +method, when invoked, must return the result of running +fragment serialization algorithm, given this as the node and options.includeShadowRoots as include shadow roots. +

    The insertAdjacentElement(where, element) -method, when invoked, must return the result of running insert adjacent, give this, +method, when invoked, must return the result of running insert adjacent, given this, where, and element.

    The From ffdc549b9a1c3f40dd59341f59712ed839a4f9da Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Fri, 17 Apr 2020 14:48:40 -0700 Subject: [PATCH 04/13] Pulled out "attach a shadow root" algorithm --- dom.bs | 58 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/dom.bs b/dom.bs index 69cace66f..26fe710d7 100644 --- a/dom.bs +++ b/dom.bs @@ -6703,11 +6703,35 @@ when invoked, must run these steps: invoked, must run these steps:

      -
    1. If this's namespace is not the HTML namespace, + +

    2. Run attach a shadow root with shadow host equal to this, + mode equal to init's {{ShadowRootInit/mode}}, and delegates focus + equal to init's {{ShadowRootInit/delegatesFocus}}.

    3. + +
    4. Return this's shadow root.

    5. + +
    + +

    The shadowRoot attribute's getter must run these +steps: + +

      +
    1. Let shadow be shadow host's shadow root. + +

    2. If shadow is null or its mode is "closed", + then return null.

    3. + +
    4. Return shadow. +

    + +

    To attach a shadow root, given a +shadow host, mode, and delegates focus, run these steps:

    + +
      +
    1. If this's namespace is not the HTML namespace, then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. -

    2. -

      If this's local name is not one of the following: +

    3. If this's local name is not a

  • -
  • If this is a shadow host whose shadow root's is declarative shadow root property is false, then throw an +

  • If this has a non-null shadow root whose + is declarative shadow root property is false, then throw an "{{NotSupportedError!!exception}}" {{DOMException}}. -

  • If this is a shadow host whose shadow root's is declarative shadow root property is true, then remove all of shadow root's children, in tree order. Return this's shadow root. +

  • If this has a non-null shadow root whose + is declarative shadow root property is true, then remove all of + shadow root's children, in tree order. Return shadow host's shadow root.

  • Let shadow be a new shadow root whose node document - is this's node document, host is this, - and mode is init's {{ShadowRootInit/mode}}. + is this's node document, host is shadow host, + and mode is mode. -

  • Set shadow's delegates focus to init's - {{ShadowRootInit/delegatesFocus}}. +

  • Set shadow's delegates focus to delegates focus.

  • Set shadow's is declarative shadow root property to false.

  • Set this's shadow root to shadow. - -

  • Return shadow. - - -

    The shadowRoot attribute's getter must run these -steps: - -

      -
    1. Let shadow be this's shadow root. - -

    2. If shadow is null or its mode is "closed", - then return null.

    3. - -
    4. Return shadow.


    From 6c35afa70a2e6237ef5bf6f628159aa5ad5a651c Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Sun, 19 Apr 2020 09:12:49 -0700 Subject: [PATCH 05/13] Add note about multiple declarative roots --- dom.bs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dom.bs b/dom.bs index 26fe710d7..f289b8d7d 100644 --- a/dom.bs +++ b/dom.bs @@ -6782,6 +6782,9 @@ steps: is declarative shadow root property is true, then remove all of shadow root's children, in tree order. Return shadow host's shadow root. +

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

  • Let shadow be a new shadow root whose node document is this's node document, host is shadow host, and mode is mode. From 2f91c8227c99a47e796d717164956d4cdc149aac Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Wed, 22 Apr 2020 10:06:01 -0700 Subject: [PATCH 06/13] Remove link to "declarative shadow root" --- dom.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom.bs b/dom.bs index f289b8d7d..bc97b4d86 100644 --- a/dom.bs +++ b/dom.bs @@ -6782,7 +6782,7 @@ steps: is declarative shadow root property is true, then remove all of shadow root's children, in tree order. Return shadow host's shadow root. -

    This means that if multiple declarative shadow roots are contained within a single shadow host, +

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

  • Let shadow be a new shadow root whose node document From 8a0ab5de58a32c2487b3438ffa0e28b58353665f Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Fri, 1 May 2020 10:05:16 -0700 Subject: [PATCH 07/13] Modified clone() to allow cloning templates with declarative SD --- dom.bs | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/dom.bs b/dom.bs index bc97b4d86..ce9987964 100644 --- a/dom.bs +++ b/dom.bs @@ -4232,8 +4232,8 @@ elements. SVG ought to do the same for its <{script}> elements, but does not cal at the moment.

    To clone a -node, with an optional document and clone children flag, run these -steps: +node, with an optional document, clone children flag, and +clone shadows flag, run these steps: @@ -4307,6 +4307,22 @@ dom-Range-extractContents, dom-Range-cloneContents --> children of node and append them to copy, with document as specified and the clone children flag being set. +

  • If the clone shadows flag is set, run these steps: + +
      +
    1. Run attach a shadow root with shadow host equal to copy, + mode equal to node's shadow root's mode, and delegates focus + equal to node's shadow root's delegates focus.

    2. + +
    3. If node's shadow root's is declarative shadow root is true, then + set copy's shadow root's is declarative shadow root property to true.

    4. + +
    5. If the clone children flag is set, clone all the + children of node's shadow root and append them to copy's shadow root, with + document as specified and the clone children flag being set. + +
    +
  • Return copy. @@ -4317,10 +4333,18 @@ invoked, must run these steps:
  • If this is a shadow root, then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. -

  • Return a clone of this, with the - clone children flag set if deep is true. +

  • Let shouldCloneShadows be true if this is a shadow host + whose shadow root's is declarative shadow root property is true, + and false otherwise. + +

  • Let clonedNode equal a clone of this, with the + clone children flag set if deep is true, and clone shadows flag set to + shouldCloneShadows. + + + A node A equals a node B if all of the following conditions are true: @@ -6906,7 +6930,9 @@ for this.

    The getInnerHTML(options) method, when invoked, must return the result of running -fragment serialization algorithm, given this as the node and options.includeShadowRoots as include shadow roots. +fragment +serialization algorithm, given this as node and options.includeShadowRoots +as include shadow roots.

    The insertAdjacentElement(where, element) From 9efcb609c930cfcd18fd04c32727d5177d85ba51 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Fri, 1 May 2020 10:20:20 -0700 Subject: [PATCH 08/13] Better logic for detecting template --- dom.bs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dom.bs b/dom.bs index ce9987964..1a798385b 100644 --- a/dom.bs +++ b/dom.bs @@ -4319,7 +4319,7 @@ dom-Range-extractContents, dom-Range-cloneContents -->

  • If the clone children flag is set, clone all the children of node's shadow root and append them to copy's shadow root, with - document as specified and the clone children flag being set. + document as specified, the clone children flag being set, and the clone shadows flag being set. @@ -4333,9 +4333,9 @@ invoked, must run these steps:
  • If this is a shadow root, then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. -

  • Let shouldCloneShadows be true if this is a shadow host - whose shadow root's is declarative shadow root property is true, - and false otherwise. +

  • If this has a non-null host, but this is not + a shadow host, then set shouldCloneShadows to true. Otherwise, set + it to false.

  • Let clonedNode equal a clone of this, with the clone children flag set if deep is true, and clone shadows flag set to @@ -4343,8 +4343,6 @@ invoked, must run these steps: - - A node A equals a node B if all of the following conditions are true: From a6a9644a24bd5a516cb25a277960405b372a9287 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Fri, 1 May 2020 12:22:47 -0700 Subject: [PATCH 09/13] Two quick fixes --- dom.bs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/dom.bs b/dom.bs index 1a798385b..b8ea4f390 100644 --- a/dom.bs +++ b/dom.bs @@ -4307,7 +4307,7 @@ dom-Range-extractContents, dom-Range-cloneContents --> children of node and append them to copy, with document as specified and the clone children flag being set. -

  • If the clone shadows flag is set, run these steps: +
  • If node is a shadow host and the clone shadows flag is set, run these steps:
    1. Run attach a shadow root with shadow host equal to copy, @@ -4333,13 +4333,9 @@ invoked, must run these steps:

    2. If this is a shadow root, then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. -

    3. If this has a non-null host, but this is not - a shadow host, then set shouldCloneShadows to true. Otherwise, set - it to false. -

    4. Let clonedNode equal a clone of this, with the - clone children flag set if deep is true, and clone shadows flag set to - shouldCloneShadows. + clone children flag set if deep is true, and the clone shadows flag + set if this is a {{DocumentFragment}}.

    From 33f4adfe9f0065056e47f8ca3a6f01064e7bb186 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Fri, 1 May 2020 12:41:50 -0700 Subject: [PATCH 10/13] Cleanup --- dom.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dom.bs b/dom.bs index b8ea4f390..09c760ed1 100644 --- a/dom.bs +++ b/dom.bs @@ -4333,9 +4333,9 @@ invoked, must run these steps:
  • If this is a shadow root, then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. -

  • Let clonedNode equal a clone of this, with the - clone children flag set if deep is true, and the clone shadows flag - set if this is a {{DocumentFragment}}. +

  • Return a clone of this, with the + clone children flag set if deep is true, and the + clone shadows flag set if this is a {{DocumentFragment}}. From 097c51201b6c69483f54e4a81d7be5da44e1aeb0 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Fri, 1 May 2020 14:19:24 -0700 Subject: [PATCH 11/13] Only template contents --- dom.bs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dom.bs b/dom.bs index 09c760ed1..18168f2c8 100644 --- a/dom.bs +++ b/dom.bs @@ -4335,7 +4335,8 @@ invoked, must run these steps:

  • Return a clone of this, with the clone children flag set if deep is true, and the - clone shadows flag set if this is a {{DocumentFragment}}. + clone shadows flag set if this is a {{DocumentFragment}} whose + host is an HTML <{template}> element. From 0c4166538657d72853fd80eee2e82f0690e70740 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Tue, 5 May 2020 17:12:55 -0700 Subject: [PATCH 12/13] Fix HTML link --- dom.bs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dom.bs b/dom.bs index 18168f2c8..e41ad2a6a 100644 --- a/dom.bs +++ b/dom.bs @@ -6924,10 +6924,8 @@ for this.

    The getInnerHTML(options) -method, when invoked, must return the result of running -fragment -serialization algorithm, given this as node and options.includeShadowRoots -as include shadow roots. +method, when invoked, must return the result of running HTML fragment serialization algorithm, +given this as node and options.includeShadowRoots as include shadow roots.

    The insertAdjacentElement(where, element) From 191a88c92e1f80a7bb439b064a63fbd043204226 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Thu, 11 Jun 2020 14:40:50 -0700 Subject: [PATCH 13/13] Addressed annevk's comments --- dom.bs | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/dom.bs b/dom.bs index e41ad2a6a..a9a677ae1 100644 --- a/dom.bs +++ b/dom.bs @@ -5899,6 +5899,7 @@ dictionary ShadowRootInit { dictionary GetInnerHTMLOptions { boolean includeShadowRoots = true; + sequence<ShadowRoot> closedRoots; }; @@ -6735,7 +6736,7 @@ invoked, must run these steps: steps:

      -
    1. Let shadow be shadow host's shadow root. +

    2. Let shadow be this's shadow root.

    3. If shadow is null or its mode is "closed", then return null.

    4. @@ -6747,10 +6748,10 @@ steps: shadow host, mode, and delegates focus, run these steps:

        -
      1. If this's namespace is not the HTML namespace, +

      2. If shadow host's namespace is not the HTML namespace, then throw a "{{NotSupportedError!!exception}}" {{DOMException}}. -

      3. If this's local name is not a +

      4. If shadow host's local name is not a


      @@ -6925,7 +6927,8 @@ for this.

      The getInnerHTML(options) method, when invoked, must return the result of running HTML fragment serialization algorithm, -given this as node and options.includeShadowRoots as include shadow roots. +given this as node, options.includeShadowRoots as include shadow roots, +and options.closedRoots as closed shadow roots.

      The insertAdjacentElement(where, element)