diff --git a/dom.bs b/dom.bs index 616a18340..bf651d4e3 100644 --- a/dom.bs +++ b/dom.bs @@ -3568,7 +3568,7 @@ dom-Range-extractContents, dom-Range-cloneContents --> invoked, must run these steps:
    -
  1. If context object is a shadow root, throw a {{NotSupportedError}} +

  2. If context object is a shadow root, throw a {{NotSupportedError}} exception.

  3. Return a clone of the context object, with the @@ -4537,7 +4537,7 @@ method, when invoked, must run these steps: deep is true, the copy also includes the node's descendants. - If node is a document or a shadow root, throws a + If node is a document or a shadow root, throws a {{NotSupportedError}} exception.

    node = document . {{adoptNode(node)}} @@ -4547,14 +4547,14 @@ method, when invoked, must run these steps: document and returns it. If node is a document, throws a {{NotSupportedError}} or, if - node is a shadow root, throws a {{HierarchyRequestError}} exception. + node is a shadow root, throws a {{HierarchyRequestError}} exception. The importNode(node, deep) method, when invoked, must run these steps:
      -
    1. If node is a document or shadow root, throw a +
    2. If node is a document or shadow root, throw a {{NotSupportedError}} exception.
    3. Return a clone of @@ -4598,7 +4598,7 @@ must run these steps:
    4. If node is a document, throw a {{NotSupportedError}} exception. -
    5. If node is a shadow root, throw a {{HierarchyRequestError}} +
    6. If node is a shadow root, throw a {{HierarchyRequestError}} exception.
    7. Adopt node @@ -4962,7 +4962,7 @@ or if B's root has an associated host.

      The {{DocumentFragment}} node's host -concept is useful for HTML's <{template}> element and for shadow roots, and impacts the +concept is useful for HTML's <{template}> element and for shadow roots, and impacts the pre-insert and replace algorithms.

      @@ -4985,7 +4985,10 @@ interface ShadowRoot : DocumentFragment {

      {{ShadowRoot}} nodes are simply known as -shadow roots. +shadow roots. + +

      Shadow roots have an associated encapsulation mode +("open" or "closed").

      The host attribute's getter must return the context object's host. @@ -5027,6 +5030,9 @@ interface Element : Node { Attr? setAttributeNodeNS(Attr attr); Attr removeAttributeNode(Attr attr); + ShadowRoot attachShadow(ShadowRootInit init); + readonly attribute ShadowRoot? shadowRoot; + Element? closest(DOMString selectors); boolean matches(DOMString selectors); boolean webkitMatchesSelector(DOMString selectors); // historical alias of .matches @@ -5037,22 +5043,29 @@ interface Element : Node { Element? insertAdjacentElement(DOMString where, Element element); // historical void insertAdjacentText(DOMString where, DOMString data); // historical -}; +}; +dictionary ShadowRootInit { + required ShadowRootMode mode; +}; -{{Element}} nodes are simply -known as elements. +enum ShadowRootMode { "open", "closed" }; + + +

      {{Element}} nodes are simply known as +elements. -Elements have an associated +

      Elements have an associated namespace, namespace prefix, and local name. When an -element is created, its -local name is always given. -Unless explicitly given when an element -is created, its namespace and -namespace prefix are -null. +element is created, its local name is always given. Unless +explicitly given when an element is created, its namespace and +namespace prefix are null. + +

      Elements also have an associated +shadow root (null or a +shadow root). Null unless otherwise stated.

      An element's qualified name is its local name if its namespace prefix is null, and its @@ -5572,6 +5585,68 @@ method, when invoked, must run these steps:


      +
      +
      var shadow = element . {{attachShadow(init)}} +

      Creates a shadow root for element and returns it. + +

      var shadow = element . {{shadowRoot}} +

      Returns element's shadow root, if any, and if + shadow root's encapsulation mode is "open", and + null otherwise. +

      + +

      The attachShadow(init) method, when +invoked, must run these steps: + +

        +
      1. If context object is not a custom element, and is not an + element whose namespace is the HTML namespace and + local name is + "article", + "aside", + "blockquote", + "body", + "div", + "footer", + "h1", + "h2", + "h3", + "h4", + "h5", + "h6", + "header", + "nav", + "p", + "section", or + "span", then throw a {{NotSupportedError}} exception. + +

      2. If context object's shadow root is non-null, then throw a + {{InvalidStateError}} exception. + +

      3. Let shadow be a new shadow root whose node document is + context object's node document, host is + context object, and encapsulation mode is init's + {{ShadowRootInit/mode}}. + +

      4. Set context object's shadow root to shadow. + +

      5. Return shadow. +

      + +

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

        +
      1. Let shadow be context object's shadow root. + +

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

      3. Return shadow. +

      + +
      +
      element . {{closest(selectors)}}
      Returns the first (starting at element) diff --git a/dom.html b/dom.html index ac48f3956..6eb63bc67 100644 --- a/dom.html +++ b/dom.html @@ -2759,7 +2759,8 @@

      Element host; }; -

      ShadowRoot nodes are simply known as shadow roots.

      +

      ShadowRoot nodes are simply known as shadow roots.

      +

      Shadow roots have an associated encapsulation mode ("open" or "closed").

      The host attribute’s getter must return the context object’s host.

      For now you can find more information about this object in Shadow DOM. The DOM Standard will be updated over time to cover more details.

      @@ -2793,6 +2794,9 @@

      Attr? setAttributeNodeNS(Attr attr); Attr removeAttributeNode(Attr attr); + ShadowRoot attachShadow(ShadowRootInit init); + readonly attribute ShadowRoot? shadowRoot; + Element? closest(DOMString selectors); boolean matches(DOMString selectors); boolean webkitMatchesSelector(DOMString selectors); // historical alias of .matches @@ -2803,12 +2807,18 @@

      Element? insertAdjacentElement(DOMString where, Element element); // historical void insertAdjacentText(DOMString where, DOMString data); // historical -}; -

      Element nodes are simply -known as elements.

      -

      Elements have an associated namespace, namespace prefix, and local name. When an element is created, its local name is always given. -Unless explicitly given when an element is created, its namespace and namespace prefix are -null.

      +}; + +dictionary ShadowRootInit { + required ShadowRootMode mode; +}; + +enum ShadowRootMode { "open", "closed" }; + +

      Element nodes are simply known as elements.

      +

      Elements have an associated namespace, namespace prefix, and local name. When an element is created, its local name is always given. Unless +explicitly given when an element is created, its namespace and namespace prefix are null.

      +

      Elements also have an associated shadow root (null or a shadow root). Null unless otherwise stated.

      An element’s qualified name is its local name if its namespace prefix is null, and its namespace prefix, followed by ":", followed by its local name, otherwise.

      User agents could have this as an internal slot as an optimization, but are not required to do so. The standard has this concept for readability.

      @@ -3059,6 +3069,58 @@

      Return attr.


    +
    +
    var shadow = element . attachShadow(init) +
    +

    Creates a shadow root for element and returns it.

    +
    var shadow = element . shadowRoot +
    +

    Returns element’s shadow root, if any, and if shadow root’s encapsulation mode is "open", and + null otherwise.

    +
    +

    The attachShadow(init) method, when +invoked, must run these steps:

    +
      +
    1. +

      If context object is not a custom element, and is not an element whose namespace is the HTML namespace and local name is + "article", + "aside", + "blockquote", + "body", + "div", + "footer", + "h1", + "h2", + "h3", + "h4", + "h5", + "h6", + "header", + "nav", + "p", + "section", or + "span", then throw a NotSupportedError exception.

      +
    2. +

      If context object’s shadow root is non-null, then throw a InvalidStateError exception.

      +
    3. +

      Let shadow be a new shadow root whose node document is context object’s node document, host is context object, and encapsulation mode is init’s mode.

      +
    4. +

      Set context object’s shadow root to shadow.

      +
    5. +

      Return shadow.

      +
    +

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

    +
      +
    1. +

      Let shadow be context object’s shadow root.

      +
    2. +

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

      +
    3. +

      Return shadow.

      +
    +
    element . closest(selectors)
    Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise. @@ -4722,6 +4784,7 @@

    append(nodes...), in §4.2.3
  4. ASCII case-insensitive, in §2.2
  5. ASCII case-insensitively, in §2.2 +
  6. attachShadow(init), in §4.9
  7. AT_TARGET, in §3.2
  8. Attr, in §4.9.2
  9. attribute, in §4.9.2 @@ -4930,6 +4993,7 @@

    ELEMENT_NODE, in §4.4
  10. Elements, in §4.2.6
  11. empty, in §4.2 +
  12. encapsulation mode, in §4.8
  13. encoding, in §4.5
  14. end, in §5.2
  15. endContainer, in §5.2 @@ -5126,7 +5190,12 @@

    lookupPrefix(namespace), in §4.4
  16. match a relative selectors string, in §2.4
  17. matches(selectors), in §4.9 -
  18. mode, in §4.5 +
  19. + mode +
  20. MutationCallback, in §4.3.1
  21. MutationEvent, in §8.1
  22. MutationNameEvent, in §8.1 @@ -5367,7 +5436,15 @@

    set the start, in §5.2
  23. setUserData(), in §8.2
  24. ShadowRoot, in §4.8 -
  25. shadow roots, in §4.8 +
  26. + shadow root + +
  27. shadowRoot, in §4.9 +
  28. ShadowRootInit, in §4.9 +
  29. ShadowRootMode, in §4.9
  30. SHOW_ALL, in §6.3
  31. SHOW_ATTRIBUTE, in §6.3
  32. SHOW_CDATA_SECTION, in §6.3 @@ -5895,6 +5972,9 @@

    I Attr? setAttributeNodeNS(Attr attr); Attr removeAttributeNode(Attr attr); + ShadowRoot attachShadow(ShadowRootInit init); + readonly attribute ShadowRoot? shadowRoot; + Element? closest(DOMString selectors); boolean matches(DOMString selectors); boolean webkitMatchesSelector(DOMString selectors); // historical alias of .matches @@ -5906,6 +5986,13 @@

    I Element? insertAdjacentElement(DOMString where, Element element); // historical void insertAdjacentText(DOMString where, DOMString data); // historical }; + +dictionary ShadowRootInit { + required ShadowRootMode mode; +}; + +enum ShadowRootMode { "open", "closed" }; + [Exposed=Window, LegacyUnenumerableNamedProperties] interface NamedNodeMap { readonly attribute unsigned long length;