Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 89 additions & 11 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4854,6 +4854,10 @@ and an optional <a for=/>document</a> <dfn export for="clone a node"><var>docume
<li><p>Let <var>shadowRootRegistry</var> be <var>node</var>'s <a for=Element>shadow root</a>'s
<a for=ShadowRoot>custom element registry</a>.

<li><p>If <var>shadowRootRegistry</var> <a>is a global custom element registry</a>, then set
<var>shadowRootRegistry</var> to <var>document</var>'s
<a>effective global custom element registry</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
Expand Down Expand Up @@ -4896,6 +4900,9 @@ and an optional <a for=/>document</a> <dfn export for="clone a node"><var>docume
<li><p>If <var>registry</var> is null, then set <var>registry</var> to
<var>fallbackRegistry</var>.

<li><p>If <var>registry</var> <a>is a global custom element registry</a>, then set
<var>registry</var> to <var>document</var>'s <a>effective global custom element registry</a>.

<li><p>Set <var>copy</var> to the result of <a>creating an element</a>, given
<var>document</var>, <var>node</var>'s <a for=Element>local name</a>, <var>node</var>'s
<a for=Element>namespace</a>, <var>node</var>'s <a for=Element>namespace prefix</a>,
Expand All @@ -4920,10 +4927,18 @@ and an optional <a for=/>document</a> <dfn export for="clone a node"><var>docume

<dl class=switch>
<dt>{{Document}}
<dd><p>Set <var>copy</var>'s <a for=Document>encoding</a>, <a for=Document>content type</a>,
<a for=Document>URL</a>, <a for=Document>origin</a>, <a for=Document>type</a>,
<a for=Document>mode</a>, <a for=Document>allow declarative shadow roots</a>, and
<a for=Document>custom element registry</a> to those of <var>node</var>.
<dd>
<ol>
<li><p>Set <var>copy</var>'s <a for=Document>encoding</a>, <a for=Document>content type</a>,
<a for=Document>URL</a>, <a for=Document>origin</a>, <a for=Document>type</a>,
<a for=Document>mode</a>, and <a for=Document>allow declarative shadow roots</a>, to those of
<var>node</var>.

<li><p>If <var>node</var>'s <a for=Document>custom element registry</a>'s
<a for=CustomElementRegistry>is scoped</a> is true, then set <var>copy</var>'s
<a for=Document>custom element registry</a> to <var>node</var>'s
<a for=Document>custom element registry</a>.
</ol>

<dt>{{DocumentType}}
<dd><p>Set <var>copy</var>'s <a for=DocumentType>name</a>, <a>public ID</a>, and
Expand Down Expand Up @@ -5774,6 +5789,7 @@ method steps are to return the <a>list of elements with class names <var>classNa
<p class=note>The HTML Standard will, e.g., define that for <code>html</code> and the
<a>HTML namespace</a>, the {{HTMLHtmlElement}} interface is used. [[!HTML]]

<div algorithm>
<p>The
<dfn method for=Document><code>createElement(<var>localName</var>, <var>options</var>)</code></dfn>
method steps are:
Expand All @@ -5795,7 +5811,9 @@ method steps are:
<li><p>Return the result of <a>creating an element</a> given <a>this</a>, <var>localName</var>,
<var>namespace</var>, null, <var>is</var>, true, and <var>registry</var>.
</ol>
</div>

<div algorithm>
<p>The <dfn noexport>internal <code>createElementNS</code> steps</dfn>, given <var>document</var>,
<var>namespace</var>, <var>qualifiedName</var>, and <var>options</var>, are as follows:

Expand All @@ -5811,13 +5829,17 @@ method steps are:
<var>localName</var>, <var>namespace</var>, <var>prefix</var>, <var>is</var>, true, and
<var>registry</var>.
</ol>
</div>

<div algorithm>
<p>The
<dfn method for=Document><code>createElementNS(<var>namespace</var>, <var>qualifiedName</var>, <var>options</var>)</code></dfn>
method steps are to return the result of running the
<a>internal <code>createElementNS</code> steps</a>, given <a>this</a>, <var>namespace</var>,
<var>qualifiedName</var>, and <var>options</var>.
</div>

<div algorithm>
<p>To <dfn>flatten element creation options</dfn>, given a string or {{ElementCreationOptions}}
dictionary <var>options</var> and a <a for=/>document</a> <var>document</var>:

Expand All @@ -5833,6 +5855,10 @@ dictionary <var>options</var> and a <a for=/>document</a> <var>document</var>:
<li><p>If <var>options</var>["{{ElementCreationOptions/customElementRegistry}}"]
<a for=map>exists</a>, then set <var>registry</var> to it.

<li><p>If <var>registry</var>'s <a for=CustomElementRegistry>is scoped</a> is false and
<var>registry</var> is not <var>document</var>'s <a for=Document>custom element registry</a>,
then <a>throw</a> a "{{NotSupportedError!!exception}}" {{DOMException}}.

<li><p>If <var>options</var>["{{ElementCreationOptions/is}}"] <a for=map>exists</a>, then set
<var>is</var> to it.

Expand All @@ -5848,6 +5874,7 @@ dictionary <var>options</var> and a <a for=/>document</a> <var>document</var>:

<p class=note>{{Document/createElement()}} and {{Document/createElementNS()}}'s <var>options</var>
parameter is allowed to be a string for web compatibility.
</div>

<p>The <dfn method for=Document><code>createDocumentFragment()</code></dfn> method steps are to
return a new {{DocumentFragment}} <a for=/>node</a> whose <a for=Node>node document</a> is
Expand Down Expand Up @@ -5944,6 +5971,10 @@ method steps are:

<li><p>If <var>options</var>["{{ImportNodeOptions/customElementRegistry}}"]
<a for=map>exists</a>, then set <var>registry</var> to it.

<li><p>If <var>registry</var>'s <a for=CustomElementRegistry>is scoped</a> is false and
<var>registry</var> is not <a>this</a>'s <a for=Document>custom element registry</a>, then
<a>throw</a> a "{{NotSupportedError!!exception}}" {{DOMException}}.
</ol>

<li><p>If <var>registry</var> is null, then set <var>registry</var> to the result of
Expand All @@ -5956,11 +5987,14 @@ method steps are:
</ol>
</div>

<div algorithm>
<p><a lt="Other applicable specifications">Specifications</a> may define
<dfn export id=concept-node-adopt-ext>adopting steps</dfn> for all or some <a for=/>nodes</a>. The
algorithm is passed <var>node</var> and <var>oldDocument</var>, as indicated in the <a>adopt</a>
algorithm.
algorithm is passed <var ignore>node</var> and <var ignore>oldDocument</var>, as indicated in the
<a>adopt</a> algorithm.
</div>

<div algorithm>
<p>To <dfn export id=concept-node-adopt>adopt</dfn> a <var>node</var> into a <var>document</var>, run
these steps:

Expand All @@ -5981,9 +6015,24 @@ these steps:
<ol>
<li><p>Set <var>inclusiveDescendant</var>'s <a for=Node>node document</a> to <var>document</var>.

<li><p>If <var>inclusiveDescendant</var> is an <a for=/>element</a>, then set the
<a for=Node>node document</a> of each <a>attribute</a> in <var>inclusiveDescendant</var>'s
<a for=Element>attribute list</a> to <var>document</var>.
<li><p>If <var>inclusiveDescendant</var> is a <a for=/>shadow root</a> and
<var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a>
<a>is a global custom element registry</a>, then set <var>inclusiveDescendant</var>'s
<a for=ShadowRoot>custom element registry</a> to <var>document</var>'s
<a>effective global custom element registry</a>.

<li>
<p>Otherwise, if <var>inclusiveDescendant</var> is an <a for=/>element</a>:

<ol>
<li><p>Set the <a for=Node>node document</a> of each <a>attribute</a> in
<var>inclusiveDescendant</var>'s <a for=Element>attribute list</a> to <var>document</var>.

<li><p>If <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a>
<a>is a global custom element registry</a>, then set <var>inclusiveDescendant</var>'s
<a for=Element>custom element registry</a> to <var>document</var>'s
<a>effective global custom element registry</a>.
</ol>
</ol>

<li><p>For each <var>inclusiveDescendant</var> in <var>node</var>'s
Expand All @@ -5997,7 +6046,9 @@ these steps:
<a>adopting steps</a> with <var>inclusiveDescendant</var> and <var>oldDocument</var>.
</ol>
</ol>
</div>

<div algorithm>
<p>The <dfn method for=Document><code>adoptNode(<var>node</var>)</code></dfn> method steps are:

<ol>
Expand All @@ -6014,6 +6065,24 @@ these steps:

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

<hr>

<p>Null or a {{CustomElementRegistry}} object <var>registry</var>
<dfn>is a global custom element registry</dfn> if <var>registry</var> is non-null and
<var>registry</var>'s <a for=CustomElementRegistry>is scoped</a> is false.</p>

<p>A <a for=/>document</a> <var>document</var>'s <dfn>effective global custom element registry</dfn>
is:

<ol>
<li><p>If <var>document</var>'s <a for=Document>custom element registry</a>
<a>is a global custom element registry</a>, then return <var>document</var>'s
<a for=Document>custom element registry</a>.

<li><p>Return null.
</ol>

<hr>

Expand Down Expand Up @@ -7515,8 +7584,17 @@ are:
<ol>
<li><p>Let <var>registry</var> be <a>this</a>'s <a for=Element>custom element registry</a>.

<li><p>If <var>init</var>["{{ShadowRootInit/customElementRegistry}}"] is non-null, then set
<var>registry</var> to it.
<li>
<p>If <var>init</var>["{{ShadowRootInit/customElementRegistry}}"] is non-null:

<ol>
<li><p>Set <var>registry</var> to <var>init</var>["{{ShadowRootInit/customElementRegistry}}"].

<li><p>If <var>registry</var>'s <a for=CustomElementRegistry>is scoped</a> is false and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I reading this correct that the only thing you can do with element.attachShadow({customElementRegistry: ...}) is to pass in the document's custom element registry, and anything else will throw an error? That makes it a boolean and practice, but I presume that this is a place where you're reserving some wiggle room for future changes?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can pass in document's custom element registry or a scoped custom element registry.

<var>registry</var> is not <a>this</a>'s <a>node document</a>'s
<a for=Document>custom element registry</a>, then <a>throw</a> a
"{{NotSupportedError!!exception}}" {{DOMException}}.
</ol>

<li><p>Run <a>attach a shadow root</a> with <a>this</a>,
<var>init</var>["{{ShadowRootInit/mode}}"], <var>init</var>["{{ShadowRootInit/clonable}}"],
Expand Down