Skip to content

Commit

Permalink
clone shadow hosts separately (cloning steps isn't needed as we don't…
Browse files Browse the repository at this point in the history
… call insertion steps for template's contents)
  • Loading branch information
annevk committed Dec 13, 2024
1 parent 7e5e391 commit 6d3d2f5
Showing 1 changed file with 36 additions and 22 deletions.
58 changes: 36 additions & 22 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4540,6 +4540,7 @@ algorithm is passed <var>node</var>, <var>copy</var>, and <var>subtree</var> as
<p class=note>HTML defines <a>cloning steps</a> for several elements, such as <{input}>, <{script}>,
and <{template}>. SVG ought to do the same for its <{script}> elements, but does not.

<div algorithm>
<p>To <dfn export id=concept-node-clone local-lt="clone">clone a node</dfn> given a
<a for=/>node</a> <var>node</var> and an optional <a for=/>document</a> <var>document</var> (default
<var>node</var>'s <a for=Node>node document</a>) and boolean <var>subtree</var> (default false):
Expand All @@ -4551,12 +4552,17 @@ and <{template}>. SVG ought to do the same for its <{script}> elements, but does
<li><p>Let <var>copy</var> be the result of <a>cloning a single node</a> given <var>node</var>,
<var>document</var>, and <var>subtree</var>.

<li><p><a>Clone a shadow host</a> given <var>node</var>, <var>copy</var>, <var>document</var>, and
<var>subtree</var>.

<li><p>If <var>subtree</var> is true, then <a>clone a node's children</a> given <var>node</var>,
<var>copy</var>, <var>document</var>, and <var>subtree</var>.

<li><p>Return <var>copy</var>.
</ol>
</div>

<div algorithm>
<p>To <dfn export>clone a node's children</dfn> given a <a for=/>node</a> <var>node</var>, a
<a for=/>node</a> <var>copy</var>, a <a for=/>document</a> <var>document</var>, and a boolean
<var>subtree</var>:
Expand All @@ -4571,11 +4577,16 @@ and <{template}>. SVG ought to do the same for its <{script}> elements, but does

<li><p><a for=/>Append</a> <var>childCopy</var> to <var>copy</var>.

<li><p><a>Clone a shadow host</a> given <var>child</var>, <var>childCopy</var>,
<var>document</var>, and <var>subtree</var>.

<li><p><a>Clone a node's children</a> given <var>child</var>, <var>childCopy</var>,
<var>document</var>, and <var>subtree</var>.
</ol>
</ol>
</div>

<div algorithm>
<p>To <dfn>clone a single node</dfn> given a <a for=/>node</a> <var>node</var>,
<a for=/>document</a> <var>document</var>, and boolean <var>subtree</var>:

Expand All @@ -4600,29 +4611,7 @@ and <{template}>. SVG ought to do the same for its <{script}> elements, but does

<li><p><a lt="append an attribute">Append</a> <var>copyAttribute</var> to <var>copy</var>.
</ol>
</li>

<li>
<p>If <var>node</var> is a <a for=Element>shadow host</a> and its
<a for=Element>shadow root</a>'s <a for=ShadowRoot>clonable</a> is true:

<ol>
<li><p><a for=/>Assert</a>: <var>copy</var> is not a <a for=Element>shadow host</a>.

<li><p><a>Attach a shadow root</a> with <var>copy</var>, <var>node</var>'s
<a for=Element>shadow root</a>'s <a for=ShadowRoot>mode</a>, true, <var>node</var>'s
<a for=Element>shadow root</a>'s <a for=ShadowRoot>serializable</a>, <var>node</var>'s
<a for=Element>shadow root</a>'s <a for=ShadowRoot>delegates focus</a>, and <var>node</var>'s
<a for=Element>shadow root</a>'s <a for=ShadowRoot>slot assignment</a>.

<li><p>Set <var>copy</var>'s <a for=Element>shadow root</a>'s <a for=ShadowRoot>declarative</a>
to <var>node</var>'s <a for=Element>shadow root</a>'s <a for=ShadowRoot>declarative</a>.

<li><p><a>Clone a node's children</a> given <var>node</var>'s <a for=Element>shadow root</a>,
<var>copy</var>'s <a for=Element>shadow root</a>, <var>document</var>, and <var>subtree</var>.
</ol>
</ol>
</li>

<li>
<p>Otherwise, set <var>copy</var> to a <a for=/>node</a> that <a>implements</a> the same
Expand Down Expand Up @@ -4668,6 +4657,31 @@ and <{template}>. SVG ought to do the same for its <{script}> elements, but does

<li><p>Return <var>copy</var>.
</ol>
</div>

<div algorithm>
<p>To <dfn>clone a shadow host</dfn> given a <a for=/>node</a> <var>node</var>, a <a for=/>node</a>
<var>copy</var>, a <a for=/>document</a> <var>document</var>, and a boolean <var>subtree</var>:

<ol>
<li><p>If <var>node</var> is not an <a for=/>element</a>, <a for=Element>shadow host</a>, or its
<a for=Element>shadow root</a>'s <a for=ShadowRoot>clonable</a> is false, then return.

<li><p><a for=/>Assert</a>: <var>copy</var> is not a <a for=Element>shadow host</a>.

<li><p><a>Attach a shadow root</a> with <var>copy</var>, <var>node</var>'s
<a for=Element>shadow root</a>'s <a for=ShadowRoot>mode</a>, true, <var>node</var>'s
<a for=Element>shadow root</a>'s <a for=ShadowRoot>serializable</a>, <var>node</var>'s
<a for=Element>shadow root</a>'s <a for=ShadowRoot>delegates focus</a>, and <var>node</var>'s
<a for=Element>shadow root</a>'s <a for=ShadowRoot>slot assignment</a>.

<li><p>Set <var>copy</var>'s <a for=Element>shadow root</a>'s <a for=ShadowRoot>declarative</a> to
<var>node</var>'s <a for=Element>shadow root</a>'s <a for=ShadowRoot>declarative</a>.

<li><p><a>Clone a node's children</a> given <var>node</var>'s <a for=Element>shadow root</a>,
<var>copy</var>'s <a for=Element>shadow root</a>, <var>document</var>, and <var>subtree</var>.
</ol>
</div>

<p>The <dfn method for=Node><code>cloneNode(<var>subtree</var>)</code></dfn> method steps are:

Expand Down

0 comments on commit 6d3d2f5

Please sign in to comment.