Re: [whatwg/dom] Add declarative Shadow DOM features (#892)

@annevk commented on this pull request.



> @@ -4363,6 +4363,26 @@ dom-Range-extractContents, dom-Range-cloneContents -->
  <a for=tree>children</a> of <var>node</var> and append them to <var>copy</var>, with
  <var>document</var> as specified and the <i>clone children flag</i> being set.
 
+ <li>
+  <p>If <var>node</var> is a <a for=Element>shadow host</a> whose <a for=/>shadow root</a>'s
+  <a for=ShadowRoot>clonable</a> is true:
+
+  <ol>
+   <li><p>Run <a>attach a shadow root</a> with <var>copy</var>, <var>node</var>'s <a for=/>shadow

No wrapping in phrasing-level elements such as `<a>`. (Unfortunately the requirements for DOM and HTML are still different.)

> @@ -4363,6 +4363,26 @@ dom-Range-extractContents, dom-Range-cloneContents -->
  <a for=tree>children</a> of <var>node</var> and append them to <var>copy</var>, with
  <var>document</var> as specified and the <i>clone children flag</i> being set.
 
+ <li>
+  <p>If <var>node</var> is a <a for=Element>shadow host</a> whose <a for=/>shadow root</a>'s
+  <a for=ShadowRoot>clonable</a> is true:
+
+  <ol>
+   <li><p>Run <a>attach a shadow root</a> with <var>copy</var>, <var>node</var>'s <a for=/>shadow
+   root</a>'s <a for=ShadowRoot>mode</a>, true, <var>node</var>'s <a for=/>shadow root</a>'s
+   <a>delegates focus</a>.</p></li>
+
+   <li><p>If <var>node</var>'s <a for=/>shadow root</a>'s
+   <a for=ShadowRoot>is declarative shadow root</a> is true, then set <var>copy</var>'s
+   <a for=/>shadow root</a>'s <a for=ShadowRoot>is declarative shadow root</a> property to

It's not a property.

> @@ -4363,6 +4363,26 @@ dom-Range-extractContents, dom-Range-cloneContents -->
  <a for=tree>children</a> of <var>node</var> and append them to <var>copy</var>, with
  <var>document</var> as specified and the <i>clone children flag</i> being set.
 
+ <li>
+  <p>If <var>node</var> is a <a for=Element>shadow host</a> whose <a for=/>shadow root</a>'s
+  <a for=ShadowRoot>clonable</a> is true:
+
+  <ol>
+   <li><p>Run <a>attach a shadow root</a> with <var>copy</var>, <var>node</var>'s <a for=/>shadow
+   root</a>'s <a for=ShadowRoot>mode</a>, true, <var>node</var>'s <a for=/>shadow root</a>'s
+   <a>delegates focus</a>.</p></li>

No need for closing tags in DOM.

> + <li>
+  <p>If <var>node</var> is a <a for=Element>shadow host</a> whose <a for=/>shadow root</a>'s
+  <a for=ShadowRoot>clonable</a> is true:
+
+  <ol>
+   <li><p>Run <a>attach a shadow root</a> with <var>copy</var>, <var>node</var>'s <a for=/>shadow
+   root</a>'s <a for=ShadowRoot>mode</a>, true, <var>node</var>'s <a for=/>shadow root</a>'s
+   <a>delegates focus</a>.</p></li>
+
+   <li><p>If <var>node</var>'s <a for=/>shadow root</a>'s
+   <a for=ShadowRoot>is declarative shadow root</a> is true, then set <var>copy</var>'s
+   <a for=/>shadow root</a>'s <a for=ShadowRoot>is declarative shadow root</a> property to
+   true.</p></li>
+
+   <li>If the <i>clone children flag</i> is set, <a lt="clone a node">clone</a> all the
+   <a>children</a> of <var>node</var>'s <a for=/>shadow root</a> and append them to

append needs an xref and I suspect we don't want to append them, but rather append the results?

> @@ -4862,8 +4882,9 @@ known as <dfn export id=concept-document lt="document">documents</dfn>.
 <dfn export for=Document id=concept-document-content-type>content type</dfn> (a string),
 <dfn export for=Document id=concept-document-url>URL</dfn> (a <a for=/>URL</a>),
 <dfn export for=Document id=concept-document-origin>origin</dfn> (an <a for=/>origin</a>),
-<dfn export for=Document id=concept-document-type>type</dfn> ("<code>xml</code>" or "<code>html</code>"), and
-<dfn export for=Document id=concept-document-mode>mode</dfn> ("<code>no-quirks</code>", "<code>quirks</code>", or "<code>limited-quirks</code>").
+<dfn export for=Document id=concept-document-type>type</dfn> ("<code>xml</code>" or "<code>html</code>"),
+<dfn export for=Document id=concept-document-mode>mode</dfn> ("<code>no-quirks</code>", "<code>quirks</code>", or "<code>limited-quirks</code>"), and
+<dfn export for=Document>allow declarative shadow roots</dfn> ("<code>allow</code>", "<code>deny</code>", or "<code>unset</code>").</p>

No need for an end tag.

> @@ -5762,13 +5785,19 @@ It is initially set to false.</p>
 <p><a for=/>Shadow roots</a> have an associated
 <dfn export for=ShadowRoot>available to element internals</dfn>. It is initially set to false.</p>
 
+<p><a for=/>Shadow roots</a> have an associated <dfn export for=ShadowRoot>is declarative shadow

No wrapping inside a phrasing-level element. So wrap before `<dfn` I suspect.

> @@ -6727,11 +6757,34 @@ are:
 <p>The <dfn method for=Element><code>attachShadow(<var>init</var>)</code></dfn> method steps are:
 
 <ol>
- <li><p>If <a>this</a>'s <a for=Element>namespace</a> is not the <a>HTML namespace</a>,
+ <li><p>Run <a>attach a shadow root</a> with <a>this</a>, <var>init</var>'s
+ {{ShadowRootInit/mode}}, <var>init</var>'s {{ShadowRootInit/clonable}}, and <var>init</var>'s

It needs to be `<var>init<var>["{{ShadowRootInit/mode}}"]` when you reference members from a dictionary (map syntax).

> @@ -6727,11 +6757,34 @@ are:
 <p>The <dfn method for=Element><code>attachShadow(<var>init</var>)</code></dfn> method steps are:
 
 <ol>
- <li><p>If <a>this</a>'s <a for=Element>namespace</a> is not the <a>HTML namespace</a>,
+ <li><p>Run <a>attach a shadow root</a> with <a>this</a>, <var>init</var>'s
+ {{ShadowRootInit/mode}}, <var>init</var>'s {{ShadowRootInit/clonable}}, and <var>init</var>'s
+ {{ShadowRootInit/delegatesFocus}}.</p></li>
+
+ <li><p>Return <a>this</a>'s <a for=Element>shadow root</a>.</p></li>
+</ol>
+
+<p>The <dfn attribute for=Element><code>shadowRoot</code></dfn> attribute's getter steps are:

```suggestion
<p>The <dfn attribute for=Element><code>shadowRoot</code></dfn> getter steps are:
```

> +
+ <li><p>Return <a>this</a>'s <a for=Element>shadow root</a>.</p></li>
+</ol>
+
+<p>The <dfn attribute for=Element><code>shadowRoot</code></dfn> attribute's getter steps are:
+
+<ol>
+ <li><p>Let <var>shadow</var> be <a>this</a>'s <a for=Element>shadow root</a>.
+
+ <li><p>If <var>shadow</var> is null or its <a for=ShadowRoot>mode</a> is "<code>closed</code>",
+ then return null.</p></li>
+
+ <li><p>Return <var>shadow</var>.
+</ol>
+
+<p>To <dfn id=concept-attach-a-shadow-root>attach a shadow root</dfn>, given a <a for=Element>shadow

No newline in phrasing-level elements.

> @@ -4862,8 +4882,9 @@ known as <dfn export id=concept-document lt="document">documents</dfn>.
 <dfn export for=Document id=concept-document-content-type>content type</dfn> (a string),
 <dfn export for=Document id=concept-document-url>URL</dfn> (a <a for=/>URL</a>),
 <dfn export for=Document id=concept-document-origin>origin</dfn> (an <a for=/>origin</a>),
-<dfn export for=Document id=concept-document-type>type</dfn> ("<code>xml</code>" or "<code>html</code>"), and
-<dfn export for=Document id=concept-document-mode>mode</dfn> ("<code>no-quirks</code>", "<code>quirks</code>", or "<code>limited-quirks</code>").
+<dfn export for=Document id=concept-document-type>type</dfn> ("<code>xml</code>" or "<code>html</code>"),
+<dfn export for=Document id=concept-document-mode>mode</dfn> ("<code>no-quirks</code>", "<code>quirks</code>", or "<code>limited-quirks</code>"), and
+<dfn export for=Document>allow declarative shadow roots</dfn> ("<code>allow</code>", "<code>deny</code>", or "<code>unset</code>").</p>

Can you explain the need for a tri-state?

> +
+ <li><p>Return <a>this</a>'s <a for=Element>shadow root</a>.</p></li>
+</ol>
+
+<p>The <dfn attribute for=Element><code>shadowRoot</code></dfn> attribute's getter steps are:
+
+<ol>
+ <li><p>Let <var>shadow</var> be <a>this</a>'s <a for=Element>shadow root</a>.
+
+ <li><p>If <var>shadow</var> is null or its <a for=ShadowRoot>mode</a> is "<code>closed</code>",
+ then return null.</p></li>
+
+ <li><p>Return <var>shadow</var>.
+</ol>
+
+<p>To <dfn id=concept-attach-a-shadow-root>attach a shadow root</dfn>, given a <a for=Element>shadow

But also, the element isn't necessarily a shadow host at this point, right?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/892#pullrequestreview-1210039993
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/pull/892/review/1210039993@github.com>

Received on Thursday, 8 December 2022 13:11:21 UTC