From 385fe0d94d71ce78d9731b32b69b5d3c2e84f348 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Wed, 8 Apr 2020 13:40:33 -0700 Subject: [PATCH 01/14] First cut at adding declarative Shadow DOM More edits Fixup Cleanup Add language for content Add shadow root serialization Link to new "attach a shadow root" algorithm. Added exception handling. Add early-out for topmost node Added shadowroot to HTMLTemplateElement for feature detection Addressed annevk's comments Add available_to_internals = true Add declarative shadow dom opt-in mechanics Trying, unsuccessfully, to get rid of "parse error while closing p element" Remove data-x for instance checks Merge fixup Rename include shadow roots state Strip out serialization stuff Lint cleanup Fix closing tags Fix dfn Fix conformance error Address all comments Fix lint First cut at streaming DSD definition Address some comments Address @rniwa comments Capitalization Rename shadowrootmode and add clonable Address comments Address comments Line length Fix regular document parsing Address comments Update to match DOM's new `declarative` Clean up call to attach a shadow root Address speculative parser comment Replace tri-state with boolean Allow about:blank Address annevk comments Address annevk comments Report the exception --- source | 216 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 169 insertions(+), 47 deletions(-) diff --git a/source b/source index 9d0696e5ef7..c1afd049127 100644 --- a/source +++ b/source @@ -3121,6 +3121,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • Element interface
  • attachShadow() method.
  • An element's shadow root
  • +
  • A shadow root's mode
  • +
  • A shadow root's declarative flag
  • +
  • The attach a shadow root algorithm
  • The retargeting algorithm
  • Node interface
  • NodeList interface
  • @@ -3233,7 +3236,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute callback
  • The encoding (herein the character encoding), - mode, and + mode, + allow declarative shadow roots, and content type of a Document
  • The distinction between XML documents and HTML documents
  • @@ -62973,6 +62977,7 @@ not-slash = %x0000-002E / %x0030-10FFFF
    Nothing (for clarification, see example).
    Content attributes:
    Global attributes
    +
    shadowrootmode
    Accessibility considerations:
    For authors.
    @@ -62984,6 +62989,7 @@ interface HTMLTemplateElement : HTMLElement { [HTMLConstructor] constructor(); readonly attribute DocumentFragment content; + [CEReactions] attribute DOMString? shadowRootMode; };
    Uses HTMLTemplateElement.
    @@ -62994,6 +63000,18 @@ interface HTMLTemplateElement : HTMLElement {

    In a rendering, the template element represents nothing.

    +

    The shadowrootmode content attribute is an + enumerated attribute whose keywords are open and closed. The keyword "open" maps to the open + state, and the keyword "closed" maps to the closed state. In + addition, there is a third state, the none state, which is the + missing value default and the + invalid value default. When the HTML + parser encounters a template element with shadowrootmode in the open or closed + state, it will create a "declarative" shadow root.

    +

    The template contents of a template element are not children of the element itself.

    @@ -63045,11 +63063,11 @@ interface HTMLTemplateElement : HTMLElement {
    -

    Each template element has an associated DocumentFragment object that - is its template contents. The template contents have no conformance requirements. When a template element - is created, the user agent must run the following steps to establish the template - contents:

    +

    Each template element has an associated DocumentFragment or + ShadowRoot object that is its template contents. The template contents + have no conformance requirements. When a template element's + template contents is first accessed, the user agent must run the following steps to + establish the template contents:

    1. Let doc be the template element's node document's appropriate template contents owner @@ -63121,8 +63139,13 @@ interface HTMLTemplateElement : HTMLElement {

    The content IDL attribute must return the - template element's template contents.

    + data-x="dom-template-content">content getter steps are to return template's + template contents, if the template contents is a DocumentFragment, + or null otherwise.

    + +

    The shadowRootMode IDL attribute must + reflect the shadowrootmode content + attribute, limited to only known values.


    @@ -94893,8 +94916,7 @@ interface BeforeUnloadEvent : Event {
    is initial about:blank
    true
    -
    about base URL
    -
    creatorBaseURL
    +
    true
    @@ -100806,8 +100828,7 @@ location.href = '#foo';
    current document readiness
    "loading"
    -
    about base URL
    -
    navigationParams's about base URL
    +
    true
    @@ -109482,7 +109503,7 @@ document.body.appendChild(frame)
    parser = new DOMParser()

    Constructs a new DOMParser object.

    -
    document = parser.parseFromString(string, type)
    +
    document = parser.parseFromString(string, type, options)

    Parses string using either the HTML or XML parser, according to type, and returns the resulting Document. type can be "text/html" @@ -109500,6 +109521,8 @@ document.body.appendChild(frame)

    Values other than the above for type will cause a TypeError exception to be thrown.

    + +

    The options parameter contains options that affect how string is parsed.

    @@ -109513,7 +109536,7 @@ document.body.appendChild(frame) interface DOMParser { constructor(); - [NewObject] Document parseFromString(DOMString string, DOMParserSupportedType type); + [NewObject] Document parseFromString(DOMString string, DOMParserSupportedType type, optional ParseFromStringOptions options = {}); }; enum DOMParserSupportedType { @@ -109522,7 +109545,12 @@ enum DOMParserSupportedType { "application/xml", "application/xhtml+xml", "image/svg+xml" -}; +}; + +dictionary ParseFromStringOptions { + boolean declarativeShadowRoots = false; +}; +
    @@ -109531,7 +109559,7 @@ enum DOMParserSupportedType {

    The parseFromString(string, - type) method steps are:

    + type, options) method steps are:

    1. @@ -109550,6 +109578,10 @@ enum DOMParserSupportedType { meta elements found while parsing string will have no effect.

    2. +
    3. Set document's allow declarative shadow roots + equal to options["declarativeShadowRoots"].

    4. +
    5. Switch on type:

      @@ -123642,12 +123674,39 @@ dictionary StorageEventInit : EventInit {
      +

      To insert an element at the adjusted insertion location with an element + element:

      + +
        +
      1. Let the adjusted insertion location be the appropriate place for + inserting a node.

      2. + +
      3. If it is not possible to insert element at the adjusted insertion + location, abort these steps.

      4. + +
      5. If the parser was not created as part of the HTML fragment parsing + algorithm, then push a new element queue onto element's + relevant agent's custom element reactions stack.

      6. + +
      7. Insert element at the adjusted insertion location.

      8. + +
      9. If the parser was not created as part of the HTML fragment parsing + algorithm, then pop the element queue from element's + relevant agent's custom element reactions stack, and invoke + custom element reactions in that queue.

      10. +
      + +

      If the adjusted insertion location cannot accept more + elements, e.g., because it's a Document that already has an element child, then + element is dropped on the floor.

      +

      When the steps below require the user agent to insert a foreign element for a token - in a given namespace, the user agent must run these steps:

      + in a given namespace and with boolean only add to element stack, the user agent must + run these steps:

      1. Let the adjusted insertion location be the appropriate place for @@ -123660,27 +123719,8 @@ dictionary StorageEventInit : EventInit { parent being the element in which the adjusted insertion location finds itself.

      2. -
      3. -

        If it is possible to insert element at the adjusted insertion location, - then:

        - -
          -
        1. If the parser was not created as part of the HTML fragment parsing - algorithm, then push a new element queue onto element's - relevant agent's custom element reactions stack.

        2. - -
        3. Insert element at the adjusted insertion location.

        4. - -
        5. If the parser was not created as part of the HTML fragment parsing - algorithm, then pop the element queue from element's - relevant agent's custom element reactions stack, and invoke - custom element reactions in that queue.

        6. -
        - -

        If the adjusted insertion location cannot accept more - elements, e.g. because it's a Document that already has an element child, then - element is dropped on the floor.

        -
      4. +
      5. If only add to element stack is false, then run insert an element at the + adjusted insertion location with element.

      6. Push element onto the stack of open elements so that it is the new current node.

      7. @@ -123690,7 +123730,7 @@ dictionary StorageEventInit : EventInit {

        When the steps below require the user agent to insert an HTML element for a token, the user agent must insert a foreign element for the token, in the HTML - namespace.

        + namespace and with only add to element stack set to false.


        @@ -124388,7 +124428,7 @@ document.body.appendChild(text);
        A start tag whose tag name is "template"
        -

        Insert an HTML element for the token.

        +

        Let template start tag be the start tag.

        Insert a marker at the end of the list of active formatting elements.

        @@ -124401,6 +124441,80 @@ document.body.appendChild(text);

        Push "in template" onto the stack of template insertion modes so that it is the new current template insertion mode.

        + +

        Let the adjusted insertion location be the appropriate place for inserting + a node.

        + +

        Let intended parent be the element in which the adjusted insertion + location finds itself.

        + +

        Let document be intended parent's node document.

        + +

        Template start tag is a declarative shadow root start tag if all of + the following are true:

        + +
          +
        • Template start tag has an attribute with the name shadowrootmode whose value is + an ASCII case-insensitive match for the strings "open" or + "closed".

        • + +
        • Document's allow + declarative shadow roots is true.

        • + +
        • The adjusted current node is not the topmost element in the stack of + open elements.

        • +
        + +

        If template start tag is not a declarative shadow root start tag, + then insert an HTML element for the token.

        + +

        Otherwise, run these steps:

        + +
          +
        1. Let the declarative shadow host element be equal to the adjusted + current node.

        2. + +
        3. Insert a foreign element for template start + tag, in the HTML namespace and with only add to element stack + set to true, setting template equal to the returned element.

        4. + +
        5. Let the declarative shadow mode be the value of template start + tag's "shadowrootmode" attribute.

        6. + +
        7. If template start tag had an attribute with the name + "shadowrootdelegatesfocus", then let declarative shadow delegates focus be true. + Otherwise let it be false.

        8. + +
        9. Run attach a shadow root with + element equal to declarative shadow host element, mode + equal to declarative shadow mode, clonable equal to true, + delegatesFocus equal to declarative shadow delegates focus, + and slotAssignment equal to "named".

        10. + +
        11. If an exception was thrown by attach a + shadow root, then catch it, and run these steps:

          + +
            +
          1. Report the exception.

          2. +
          3. Insert an element at the adjusted insertion location with template.

          4. +
          + +

          Otherwise,

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

          2. + +
          3. Set shadow's + declarative to true.

          4. + +
          5. Set template's template contents property to + shadow.

          6. + +
          7. Set shadow's available to element internals to true.

          8. +
          +
        An end tag whose tag name is "template"
        @@ -125488,7 +125602,7 @@ document.body.appendChild(text); attributes, in particular XLink.)

        Insert a foreign element for the token, in the MathML - namespace.

        + namespace with only add to element stack set to false.

        Mason Mize, Mathias Bynens, Mathieu Henri, From b595e73f952814b9d4d77e4e2fb3407e4d5088b8 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Fri, 15 Sep 2023 10:15:35 -0700 Subject: [PATCH 02/14] Merge fixup and remove DOMParser stuff --- source | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/source b/source index c1afd049127..295e5cd5b8c 100644 --- a/source +++ b/source @@ -94916,6 +94916,11 @@ interface BeforeUnloadEvent : Event {
        is initial about:blank
        true
        +
        about base URL
        +
        creatorBaseURL
        + +
        allow declarative shadow + roots
        true
        @@ -100828,6 +100833,11 @@ location.href = '#foo';
        current document readiness
        "loading"
        +
        about base URL
        +
        navigationParams's about base URL
        + +
        allow declarative shadow + roots
        true
        @@ -109503,7 +109513,7 @@ document.body.appendChild(frame)
        parser = new DOMParser()

        Constructs a new DOMParser object.

        -
        document = parser.parseFromString(string, type, options)
        +
        document = parser.parseFromString(string, type)

        Parses string using either the HTML or XML parser, according to type, and returns the resulting Document. type can be "text/html" @@ -109521,8 +109531,6 @@ document.body.appendChild(frame)

        Values other than the above for type will cause a TypeError exception to be thrown.

        - -

        The options parameter contains options that affect how string is parsed.

        @@ -109536,7 +109544,7 @@ document.body.appendChild(frame) interface DOMParser { constructor(); - [NewObject] Document parseFromString(DOMString string, DOMParserSupportedType type, optional ParseFromStringOptions options = {}); + [NewObject] Document parseFromString(DOMString string, DOMParserSupportedType type); }; enum DOMParserSupportedType { @@ -109545,12 +109553,7 @@ enum DOMParserSupportedType { "application/xml", "application/xhtml+xml", "image/svg+xml" -}; - -dictionary ParseFromStringOptions { - boolean declarativeShadowRoots = false; -}; - +};
        @@ -109559,7 +109562,7 @@ dictionary ParseFromStringOptions {

        The parseFromString(string, - type, options) method steps are:

        + type) method steps are:

        1. @@ -109578,10 +109581,6 @@ dictionary ParseFromStringOptions { meta elements found while parsing string will have no effect.

        2. -
        3. Set document's allow declarative shadow roots - equal to options["declarativeShadowRoots"].

        4. -
        5. Switch on type:

          From b1f8e5df5f7d15747050aee04f0ac5733f1f1cca Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Mon, 18 Sep 2023 09:12:09 -0700 Subject: [PATCH 03/14] Address comments --- source | 92 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/source b/source index 295e5cd5b8c..18176a2d989 100644 --- a/source +++ b/source @@ -3122,7 +3122,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
        6. attachShadow() method.
        7. An element's shadow root
        8. A shadow root's mode
        9. -
        10. A shadow root's declarative flag
        11. +
        12. A shadow root's declarative member
        13. The attach a shadow root algorithm
        14. The retargeting algorithm
        15. Node interface
        16. @@ -63064,9 +63064,9 @@ interface HTMLTemplateElement : HTMLElement {

          Each template element has an associated DocumentFragment or - ShadowRoot object that is its template contents. The template contents - have no conformance requirements. When a template element's - template contents is first accessed, the user agent must run the following steps to + ShadowRoot object that is its template contents. The template + contents have no conformance requirements. When a + template element is created, the user agent must run the following steps to establish the template contents:

            @@ -63140,8 +63140,8 @@ interface HTMLTemplateElement : HTMLElement {

            The content getter steps are to return template's - template contents, if the template contents is a DocumentFragment, - or null otherwise.

            + template contents, if the template contents is not a ShadowRoot + node, or null otherwise.

            The shadowRootMode IDL attribute must reflect the shadowrootmode content @@ -123728,8 +123728,8 @@ dictionary StorageEventInit : EventInit {

          When the steps below require the user agent to insert an HTML element for a token, - the user agent must insert a foreign element for the token, in the HTML - namespace and with only add to element stack set to false.

          + the user agent must insert a foreign element for the token, with HTML + namespace and false.


          @@ -124449,13 +124449,12 @@ document.body.appendChild(text);

          Let document be intended parent's node document.

          -

          Template start tag is a declarative shadow root start tag if all of - the following are true:

          +

          If any of the following are false:

          • Template start tag has an attribute with the name shadowrootmode whose value is - an ASCII case-insensitive match for the strings "open" or + an ASCII case-insensitive match for "open" or "closed".

          • Document's allow @@ -124465,54 +124464,53 @@ document.body.appendChild(text); open elements.

          -

          If template start tag is not a declarative shadow root start tag, - then insert an HTML element for the token.

          +

          then insert an HTML element for the token.

          Otherwise, run these steps:

            -
          1. Let the declarative shadow host element be equal to the adjusted - current node.

          2. +
          3. Let declarative shadow host element be adjusted current + node.

          4. Insert a foreign element for template start - tag, in the HTML namespace and with only add to element stack - set to true, setting template equal to the returned element.

          5. + tag, with HTML namespace and true, setting template + to the returned element.

            -
          6. Let the declarative shadow mode be the value of template start - tag's "shadowrootmode" attribute.

          7. +
          8. Let declarative shadow mode be template start tag's + "shadowrootmode".

          9. If template start tag had an attribute with the name "shadowrootdelegatesfocus", then let declarative shadow delegates focus be true. Otherwise let it be false.

          10. -
          11. Run attach a shadow root with - element equal to declarative shadow host element, mode - equal to declarative shadow mode, clonable equal to true, - delegatesFocus equal to declarative shadow delegates focus, - and slotAssignment equal to "named".

          12. +
          13. Attach a shadow root with + declarative shadow host element, declarative shadow mode, + true, declarative shadow delegates focus, and "named".

          14. -
          15. If an exception was thrown by attach a - shadow root, then catch it, and run these steps:

            +
          16. +

            If an exception was thrown by attach a + shadow root, then catch it, and run these steps:

            -
              -
            1. Report the exception.

            2. -
            3. Insert an element at the adjusted insertion location with template.

            4. -
            +
              +
            1. Report the exception.

            2. +
            3. Insert an element at the adjusted insertion location with template.

            4. +
            -

            Otherwise,

            +

            Otherwise,

            -
              -
            1. Let shadow be declarative shadow host element's - shadow root.

            2. +
                +
              1. Let shadow be declarative shadow host element's + shadow root.

              2. -
              3. Set shadow's - declarative to true.

              4. +
              5. Set shadow's + declarative to true.

              6. -
              7. Set template's template contents property to - shadow.

              8. +
              9. Set template's template contents property to + shadow.

              10. -
              11. Set shadow's available to element internals to true.

              12. -
              +
            3. Set shadow's available to element internals to true.

            4. +
            +
          @@ -125600,8 +125598,8 @@ document.body.appendChild(text);

          Adjust foreign attributes for the token. (This fixes the use of namespaced attributes, in particular XLink.)

          -

          Insert a foreign element for the token, in the MathML - namespace with only add to element stack set to false.

          +

          Insert a foreign element for the token, with MathML namespace + and false.

          + Mason Freed, Mason Mize, Mathias Bynens, Mathieu Henri, From ac1eb01a1ffb80262f79635fc8603f01d8d52c95 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Mon, 18 Sep 2023 16:31:14 -0700 Subject: [PATCH 04/14] Remove nullable --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index 18176a2d989..8ce3d14b5c3 100644 --- a/source +++ b/source @@ -62989,7 +62989,7 @@ interface HTMLTemplateElement : HTMLElement { [HTMLConstructor] constructor(); readonly attribute DocumentFragment content; - [CEReactions] attribute DOMString? shadowRootMode; + [CEReactions] attribute DOMString shadowRootMode; };
          Uses HTMLTemplateElement.
          From 84faf12e7ce4356b5733e71da182e9cfb40b4aae Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Thu, 28 Sep 2023 17:15:22 -0700 Subject: [PATCH 05/14] Address comments --- source | 58 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/source b/source index 8ce3d14b5c3..470d97fecf4 100644 --- a/source +++ b/source @@ -62978,6 +62978,7 @@ not-slash = %x0000-002E / %x0030-10FFFF
          Content attributes:
          Global attributes
          shadowrootmode
          +
          shadowrootdelegatesfocus
          Accessibility considerations:
          For authors.
          @@ -62990,6 +62991,7 @@ interface HTMLTemplateElement : HTMLElement { readonly attribute DocumentFragment content; [CEReactions] attribute DOMString shadowRootMode; + [CEReactions] attribute boolean shadowRootDelegatesFocus; };
          Uses HTMLTemplateElement.
          @@ -63012,6 +63014,10 @@ interface HTMLTemplateElement : HTMLElement { data-x="attr-template-shadowrootmode">shadowrootmode in the open or closed state, it will create a "declarative" shadow root.

          +

          The shadowrootdelegatesfocus content + attribute is a boolean attribute.

          +

          The template contents of a template element are not children of the element itself.

          @@ -63063,9 +63069,9 @@ interface HTMLTemplateElement : HTMLElement {
          -

          Each template element has an associated DocumentFragment or - ShadowRoot object that is its template contents. The template - contents have no conformance requirements. When a +

          Each template element has an associated DocumentFragment + that is its template contents. The template contents have + no conformance requirements. When a template element is created, the user agent must run the following steps to establish the template contents:

          @@ -63141,12 +63147,17 @@ interface HTMLTemplateElement : HTMLElement {

          The content getter steps are to return template's template contents, if the template contents is not a ShadowRoot - node, or null otherwise.

          + node: otherwise null.

          The shadowRootMode IDL attribute must reflect the shadowrootmode content attribute, limited to only known values.

          +

          The shadowRootDelegatesFocus + IDL attribute must reflect the + shadowrootdelegatesfocus content + attribute.

          +

          The cloning steps for a template @@ -123704,7 +123715,7 @@ dictionary StorageEventInit : EventInit { Not sure what we could call them instead, though... -->

          When the steps below require the user agent to insert a foreign element for a token - in a given namespace and with boolean only add to element stack, the user agent must + in a given namespace and with a boolean only add to element stack, the user agent must run these steps:

            @@ -123728,7 +123739,7 @@ dictionary StorageEventInit : EventInit {

          When the steps below require the user agent to insert an HTML element for a token, - the user agent must insert a foreign element for the token, with HTML + the user agent must insert a foreign element for the token, with the HTML namespace and false.


          @@ -124452,36 +124463,36 @@ document.body.appendChild(text);

          If any of the following are false:

            -
          • Template start tag has an attribute with the name template start tag has an attribute with the name shadowrootmode whose value is an ASCII case-insensitive match for "open" or - "closed".

          • + "closed"; -
          • Document's allow - declarative shadow roots is true.

          • +
          • Document's allow + declarative shadow roots is true; or
          • -
          • The adjusted current node is not the topmost element in the stack of - open elements.

          • +
          • The adjusted current node is not the topmost element in the stack of + open elements,

          then insert an HTML element for the token.

          -

          Otherwise, run these steps:

          +

          Otherwise:

          1. Let declarative shadow host element be adjusted current node.

          2. -
          3. Insert a foreign element for template start - tag, with HTML namespace and true, setting template - to the returned element.

          4. +
          5. Let template be the result of insert a foreign element + for template start tag, with HTML namespace and true.

          6. Let declarative shadow mode be template start tag's "shadowrootmode".

          7. If template start tag had an attribute with the name - "shadowrootdelegatesfocus", then let declarative shadow delegates focus be true. - Otherwise let it be false.

          8. + shadowrootdelegatesfocus, + then let declarative shadow delegates focus be true. Otherwise let it be + false.

          9. Attach a shadow root with declarative shadow host element, declarative shadow mode, @@ -124495,8 +124506,10 @@ document.body.appendChild(text);

          10. Report the exception.

          11. Insert an element at the adjusted insertion location with template.

          + -

          Otherwise,

          +
        17. +

          Otherwise:

          1. Let shadow be declarative shadow host element's @@ -137294,9 +137307,14 @@ interface External { shadowrootmode template - Enables streaming declarative Shadow DOM + Enables streaming declarative shadow roots "open"; "closed" + + shadowrootdelegatesfocus + template + Sets delegatesFocus on a declarative shadow root + Boolean attribute shape area From 894ab62cfb5482ea5630d6687063675e2e0d0230 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Fri, 29 Sep 2023 12:37:56 -0700 Subject: [PATCH 06/14] Convert enumerated attribute to table --- source | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/source b/source index 470d97fecf4..a70a9e29b19 100644 --- a/source +++ b/source @@ -63004,15 +63004,33 @@ interface HTMLTemplateElement : HTMLElement {

            The shadowrootmode content attribute is an - enumerated attribute whose keywords are open and closed. The keyword "open" maps to the open - state, and the keyword "closed" maps to the closed state. In - addition, there is a third state, the none state, which is the - missing value default and the - invalid value default. When the HTML - parser encounters a template element with shadowrootmode in the open or closed - state, it will create a "declarative" shadow root.

            + enumerated attribute. The following table lists the states for this attribute:

            + + + + + + + + + + + + + + + + + + +
            State + Keywords + Brief description
            openopenThe template element represents an open declarative shadow root.
            closedclosedThe template element represents a closed declarative shadow root.
            nonenoneThe template element does not represent a shadow root.
            + +

            The shadowrootmode attribute's + invalid value default and + missing value default are both the + none state.

            The shadowrootdelegatesfocus content From 39558d7953db4f09568579583de28f57f493bf01 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Mon, 2 Oct 2023 09:17:18 -0700 Subject: [PATCH 07/14] Convert to `dir` example format for enumerated attribute --- source | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source b/source index a70a9e29b19..88c86b7930b 100644 --- a/source +++ b/source @@ -63004,27 +63004,33 @@ interface HTMLTemplateElement : HTMLElement {

            The shadowrootmode content attribute is an - enumerated attribute. The following table lists the states for this attribute:

            + enumerated attribute with the following keywords and states:

            - + + + + + + +
            State - Keywords + StateKeywords Brief description
            open open The template element represents an open declarative shadow root.
            closed closed The template element represents a closed declarative shadow root.
            none none The template element does not represent a shadow root.

            The shadowrootmode attribute's From 700fba0ba2aad3307dd7110f967aa01842cf1c8c Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Mon, 2 Oct 2023 10:08:07 -0700 Subject: [PATCH 08/14] Connect to attributes --- source | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/source b/source index 88c86b7930b..3c91e91c5f1 100644 --- a/source +++ b/source @@ -124487,10 +124487,9 @@ document.body.appendChild(text);

            If any of the following are false:

              -
            • template start tag has an attribute with the name shadowrootmode whose value is - an ASCII case-insensitive match for "open" or - "closed";
            • +
            • template start tag's shadowrootmode is in the + open state or the + closed state;
            • Document's allow declarative shadow roots is true; or
            • @@ -124511,12 +124510,12 @@ document.body.appendChild(text); for template start tag, with HTML namespace and true.

            • Let declarative shadow mode be template start tag's - "shadowrootmode".

            • + shadowrootmode attribute.

              -
            • If template start tag had an attribute with the name - shadowrootdelegatesfocus, - then let declarative shadow delegates focus be true. Otherwise let it be - false.

            • +
            • If template start tag had a + shadowrootdelegatesfocus + attribute, then let declarative shadow delegates focus be true. Otherwise let + it be false.

            • Attach a shadow root with declarative shadow host element, declarative shadow mode, From 7d4b5630edbb76363077155d9624da28c482a96c Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Mon, 2 Oct 2023 10:15:16 -0700 Subject: [PATCH 09/14] Fix the build --- source | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source b/source index 3c91e91c5f1..7ccdf5d33c1 100644 --- a/source +++ b/source @@ -124487,9 +124487,10 @@ document.body.appendChild(text);

              If any of the following are false:

                -
              • template start tag's shadowrootmode is in the - open state or the - closed state;
              • +
              • template start tag's + shadowrootmode is in the + open state or the + closed state;
              • Document's allow declarative shadow roots is true; or
              • From e2530e1fcd574a2089ab3eab85b939df34da83a6 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Wed, 4 Oct 2023 13:44:23 -0700 Subject: [PATCH 10/14] Address comments --- source | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/source b/source index 7ccdf5d33c1..0fa859bb9cf 100644 --- a/source +++ b/source @@ -63009,8 +63009,8 @@ interface HTMLTemplateElement : HTMLElement { + - @@ -63025,18 +63025,13 @@ interface HTMLTemplateElement : HTMLElement { - - - - -
                Keyword StateKeywords Brief description
                closed The template element represents a closed declarative shadow root.
                nonenoneThe template element does not represent a shadow root.

                The shadowrootmode attribute's invalid value default and missing value default are both the - none state.

                + none state.

                The shadowrootdelegatesfocus content @@ -124488,14 +124483,13 @@ document.body.appendChild(text);

                • template start tag's - shadowrootmode is in the - open state or the - closed state;
                • + shadowrootmode is not in + the open state;
                • Document's allow declarative shadow roots is true; or
                • -
                • The adjusted current node is not the topmost element in the stack of +
                • the adjusted current node is not the topmost element in the stack of open elements,
                @@ -124528,6 +124522,7 @@ document.body.appendChild(text);
                1. Report the exception.

                2. +
                3. Insert an element at the adjusted insertion location with template.

                @@ -137331,7 +137326,7 @@ interface External { shadowrootmode template - Enables streaming declarative shadow roots + Enables streaming declarative shadow roots "open"; "closed" From 8d9043c1723a05a407ea02d1a2a13ddd6d4a5c96 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Tue, 10 Oct 2023 07:59:05 -0700 Subject: [PATCH 11/14] Fix copypasta --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index 0fa859bb9cf..203d25bf991 100644 --- a/source +++ b/source @@ -124484,7 +124484,7 @@ document.body.appendChild(text);
                • template start tag's shadowrootmode is not in - the open state;
                • + the none state;
                • Document's allow declarative shadow roots is true; or
                • From d65e189df7c654fcbedcc74703b29a76f2cad770 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Tue, 10 Oct 2023 08:02:14 -0700 Subject: [PATCH 12/14] Undo shadowrootmode and linkify delegates focus --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index 203d25bf991..c989739ecfb 100644 --- a/source +++ b/source @@ -137326,13 +137326,13 @@ interface External { shadowrootmode template - Enables streaming declarative shadow roots + Enables streaming declarative shadow roots "open"; "closed" shadowrootdelegatesfocus template - Sets delegatesFocus on a declarative shadow root + Sets delegates focus on a declarative shadow root Boolean attribute shape From e148a63afeb75f807267b94c4e7028d16a810af3 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Wed, 11 Oct 2023 09:29:31 -0700 Subject: [PATCH 13/14] Update for {set|parse}HTMLUnsafe() --- source | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source b/source index c989739ecfb..d98bf247d4a 100644 --- a/source +++ b/source @@ -109757,7 +109757,7 @@ partial interface ShadowRoot {
                  1. Let newChildren be the result of the HTML fragment parsing algorithm - given contextElement and html.

                  2. + given contextElement, html, and true.

                  3. Let fragment be a new DocumentFragment whose node document is contextElement's node document.

                  4. @@ -109780,6 +109780,9 @@ partial interface ShadowRoot { data-x="concept-document-content-type">content type is "text/html".

                    +

                    Set document's allow + declarative shadow roots to true.

                    +

                    Since document does not have a browsing context, scripting is disabled.

                    @@ -128637,8 +128640,8 @@ console.assert(container.firstChild instanceof SuperP);

                    The following steps form the HTML fragment parsing algorithm. The algorithm takes as input an Element node, referred to as the context element, which gives the context for - the parser, as well as input, a string to parse, and returns a list of zero or - more nodes.

                    + the parser, input, a string to parse, and an optional boolean allow declarative + shadow roots (default false). It returns a list of zero or more nodes.

                    Parts marked fragment case in algorithms in the parser section are parts that only occur if the parser was created for the purposes of this algorithm. The algorithms have been annotated @@ -128663,6 +128666,12 @@ console.assert(container.firstChild instanceof SuperP); mode. Otherwise, leave the Document in no-quirks mode.

                    +
                  5. +

                    If allow declarative shadow roots is true, set Document's + allow declarative shadow roots + to true.

                    +
                  6. +
                  7. Create a new HTML parser, and associate it with the just created Document node.

                    From e9eccef14dcec56b795526a887bd8be3dbcda604 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 16 Oct 2023 14:45:05 +0200 Subject: [PATCH 14/14] nits --- source | 116 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 57 insertions(+), 59 deletions(-) diff --git a/source b/source index d98bf247d4a..9d3965bf3bc 100644 --- a/source +++ b/source @@ -63009,29 +63009,24 @@ interface HTMLTemplateElement : HTMLElement { - - - - - + - - - - + - - - - - +
                    KeywordStateBrief description
                    Keyword + State + Brief description
                    openopenThe template element represents an open declarative shadow root.
                    open + open + The template element represents an open declarative shadow root.
                    closedclosedThe template element represents a closed declarative shadow root.
                    closed + closed + The template element represents a closed declarative shadow root.
                    -

                    The shadowrootmode attribute's - invalid value default and - missing value default are both the - none state.

                    +

                    The shadowrootmode attribute's invalid value default and missing value default are both the none state.

                    The shadowrootdelegatesfocus content @@ -63088,11 +63083,11 @@ interface HTMLTemplateElement : HTMLElement {

                    -

                    Each template element has an associated DocumentFragment - that is its template contents. The template contents have - no conformance requirements. When a - template element is created, the user agent must run the following steps to - establish the template contents:

                    +

                    Each template element has an associated DocumentFragment object that + is its template contents. The template contents have no conformance requirements. When a template element + is created, the user agent must run the following steps to establish the template + contents:

                    1. Let doc be the template element's node document's appropriate template contents owner @@ -63164,17 +63159,18 @@ interface HTMLTemplateElement : HTMLElement {

                    The content getter steps are to return template's - template contents, if the template contents is not a ShadowRoot - node: otherwise null.

                    + data-x="dom-template-content">content getter steps are to return + template's template contents, if the template contents is + not a ShadowRoot node; otherwise null.

                    -

                    The shadowRootMode IDL attribute must - reflect the shadowrootmode content - attribute, limited to only known values.

                    +

                    The shadowRootMode IDL attribute + must reflect the shadowrootmode + content attribute, limited to only known values.

                    -

                    The shadowRootDelegatesFocus - IDL attribute must reflect the - shadowrootdelegatesfocus content +

                    The shadowRootDelegatesFocus IDL attribute + must reflect the shadowrootdelegatesfocus content attribute.


                    @@ -109756,8 +109752,8 @@ partial interface ShadowRoot { html:

                      -
                    1. Let newChildren be the result of the HTML fragment parsing algorithm - given contextElement, html, and true.

                    2. +
                    3. Let newChildren be the result of the HTML fragment parsing + algorithm given contextElement, html, and true.

                    4. Let fragment be a new DocumentFragment whose node document is contextElement's node document.

                    5. @@ -109780,14 +109776,15 @@ partial interface ShadowRoot { data-x="concept-document-content-type">content type is "text/html".

                      -

                      Set document's allow - declarative shadow roots to true.

                      -

                      Since document does not have a browsing context, scripting is disabled.

                      +
                    6. Set document's allow declarative shadow roots to + true.

                    7. +
                    8. Parse HTML from a string given document and html.

                    9. @@ -123728,17 +123725,17 @@ dictionary StorageEventInit : EventInit { custom element reactions in that queue.

                    -

                    If the adjusted insertion location cannot accept more - elements, e.g., because it's a Document that already has an element child, then - element is dropped on the floor.

                    +

                    If the adjusted insertion location cannot accept more elements, e.g., + because it's a Document that already has an element child, then element is + dropped on the floor.

                    When the steps below require the user agent to insert a foreign element for a token - in a given namespace and with a boolean only add to element stack, the user agent must - run these steps:

                    + in a given namespace and with a boolean onlyAddToElementStack, the user agent must run + these steps:

                    1. Let the adjusted insertion location be the appropriate place for @@ -123751,7 +123748,7 @@ dictionary StorageEventInit : EventInit { parent being the element in which the adjusted insertion location finds itself.

                    2. -
                    3. If only add to element stack is false, then run insert an element at the +

                    4. If onlyAddToElementStack is false, then run insert an element at the adjusted insertion location with element.

                    5. Push element onto the stack of open elements so that it is the new @@ -124516,8 +124513,8 @@ document.body.appendChild(text); it be false.

                    6. Attach a shadow root with - declarative shadow host element, declarative shadow mode, - true, declarative shadow delegates focus, and "named".

                    7. + declarative shadow host element, declarative shadow mode, true, + declarative shadow delegates focus, and "named".

                    8. If an exception was thrown by attach a @@ -124526,7 +124523,8 @@ document.body.appendChild(text);

                      1. Report the exception.

                      2. -
                      3. Insert an element at the adjusted insertion location with template.

                      4. +
                      5. Insert an element at the adjusted insertion location with + template.

                    9. @@ -127466,8 +127464,8 @@ document.body.appendChild(text);

                      Adjust foreign attributes for the token. (This fixes the use of namespaced attributes, in particular XLink in SVG.)

                      -

                      Insert a foreign element for the token, with adjusted current node's - namespace and false.

                      +

                      Insert a foreign element for the token, with adjusted current + node's namespace and false.

                      If the token has its self-closing flag set, then run the appropriate steps from the following list:

                      @@ -127900,10 +127898,11 @@ document.body.appendChild(text);

                    When the tree builder says to insert an element into a template element's - template contents, if that is a speculative mock element, - and the template element's template contents is a - DocumentFragment, instead do nothing. URLs found speculatively inside - non-declarative-shadow-root template elements must not be speculatively fetched.

                    + template contents, if that is a speculative mock element, and the + template element's template contents is not a + ShadowRoot node, instead do nothing. URLs found speculatively inside + non-declarative-shadow-root template elements might themselves be templates, and must + not be speculatively fetched.

                    @@ -128640,8 +128639,9 @@ console.assert(container.firstChild instanceof SuperP);

                    The following steps form the HTML fragment parsing algorithm. The algorithm takes as input an Element node, referred to as the context element, which gives the context for - the parser, input, a string to parse, and an optional boolean allow declarative - shadow roots (default false). It returns a list of zero or more nodes.

                    + the parser, input, a string to parse, and an optional boolean + allowDeclarativeShadowRoots (default false). It returns a list of zero or more + nodes.

                    Parts marked fragment case in algorithms in the parser section are parts that only occur if the parser was created for the purposes of this algorithm. The algorithms have been annotated @@ -128666,11 +128666,9 @@ console.assert(container.firstChild instanceof SuperP); mode. Otherwise, leave the Document in no-quirks mode.

                  8. -
                  9. -

                    If allow declarative shadow roots is true, set Document's - allow declarative shadow roots - to true.

                    -
                  10. +
                  11. If allowDeclarativeShadowRoots is true, then set the Document's + allow declarative shadow + roots to true.

                  12. Create a new HTML parser, and associate it with the just created