Skip to content

Initialize registry correctly for declarative shadow roots #11224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025
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
160 changes: 89 additions & 71 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -131675,109 +131675,127 @@ document.body.appendChild(text);

<dt>A start tag whose tag name is "template"</dt>
<dd>
<p>Let <var>template start tag</var> be the start tag.</p>
<p>Run these steps:</p>

<p>Insert a <span data-x="concept-parser-marker">marker</span> at the end of the <span>list of
active formatting elements</span>.</p>
<ol>
<li><p>Let <var>templateStartTag</var> be the start tag.</p></li>

<p>Set the <span>frameset-ok flag</span> to "not ok".</p>
<li><p>Insert a <span data-x="concept-parser-marker">marker</span> at the end of the <span>list
of active formatting elements</span>.</p></li>

<p>Switch the <span>insertion mode</span> to "<span data-x="insertion mode: in template">in
template</span>".</p>
<li><p>Set the <span>frameset-ok flag</span> to "not ok".</p></li>

<p>Push "<span data-x="insertion mode: in template">in template</span>" onto the <span>stack of
template insertion modes</span> so that it is the new <span>current template insertion
mode</span>.</p>
<li><p>Switch the <span>insertion mode</span> to "<span data-x="insertion mode: in template">in
template</span>".</p></li>

<p>Let the <var>adjusted insertion location</var> be the <span>appropriate place for inserting
a node</span>.</p>
<li><p>Push "<span data-x="insertion mode: in template">in template</span>" onto the
<span>stack of template insertion modes</span> so that it is the new <span>current template
insertion mode</span>.</p></li>

<p>Let <var>intended parent</var> be the element in which the <var>adjusted insertion
location</var> finds itself.</p>
<li><p>Let the <var>adjustedInsertionLocation</var> be the <span>appropriate place for
inserting a node</span>.</p></li>

<p>Let <var>document</var> be <var>intended parent</var>'s <span>node document</span>.</p>
<li><p>Let <var>intendedParent</var> be the element in which the
<var>adjustedInsertionLocation</var> finds itself.</p></li>

<p>If any of the following are false:</p>
<li><p>Let <var>document</var> be <var>intendedParent</var>'s <span>node
document</span>.</p></li>

<ul>
<li><var>template start tag</var>'s
<code data-x="attr-template-shadowrootmode">shadowrootmode</code> is not in
the <span data-x="attr-shadowrootmode-none-state">none</span> state;</li>
<li>
<p>If any of the following are false:</p>

<li><var>document</var>'s <span data-x="concept-document-allow-declarative-shadow-roots">allow
declarative shadow roots</span> is true; or</li>
<ul>
<li><var>templateStartTag</var>'s <code
data-x="attr-template-shadowrootmode">shadowrootmode</code> is not in the <span
data-x="attr-shadowrootmode-none-state">none</span> state;</li>

<li>the <span>adjusted current node</span> is not the topmost element in the <span>stack of
open elements</span>,</li>
</ul>
<li><var>document</var>'s <span
data-x="concept-document-allow-declarative-shadow-roots">allow declarative shadow
roots</span> is true; or</li>

<p>then <span>insert an HTML element</span> for the token.</p>
<li>the <span>adjusted current node</span> is not the topmost element in the <span>stack of
open elements</span>,</li>
</ul>

<p>Otherwise:</p>
<p>then <span>insert an HTML element</span> for the token.</p>
</li>

<ol>
<li><p>Let <var>declarative shadow host element</var> be <span>adjusted current
node</span>.</p></li>
<li>
<p>Otherwise:</p>

<li><p>Let <var>template</var> be the result of <span>insert a foreign element</span>
for <var>template start tag</var>, with <span>HTML namespace</span> and true.</p></li>
<ol>
<li><p>Let <var>declarativeShadowHostElement</var> be <span>adjusted current
node</span>.</p></li>

<li><p>Let <var>mode</var> be <var>template start tag</var>'s <code
data-x="attr-template-shadowrootmode">shadowrootmode</code> attribute's value.</p></li>
<li><p>Let <var>template</var> be the result of <span>insert a foreign element</span> for
<var>templateStartTag</var>, with <span>HTML namespace</span> and true.</p></li>

<li><p>Let <var>clonable</var> be true if <var>template start tag</var> has a <code
data-x="attr-template-shadowrootclonable">shadowrootclonable</code> attribute; otherwise
false.</p></li>
<li><p>Let <var>mode</var> be <var>templateStartTag</var>'s <code
data-x="attr-template-shadowrootmode">shadowrootmode</code> attribute's value.</p></li>

<li><p>Let <var>serializable</var> be true if <var>template start tag</var> has a <code
data-x="attr-template-shadowrootserializable">shadowrootserializable</code> attribute;
otherwise false.</p></li>
<li><p>Let <var>clonable</var> be true if <var>templateStartTag</var> has a <code
data-x="attr-template-shadowrootclonable">shadowrootclonable</code> attribute; otherwise
false.</p></li>

<li><p>Let <var>delegatesFocus</var> be true if <var>template start tag</var> has a <code
data-x="attr-template-shadowrootdelegatesfocus">shadowrootdelegatesfocus</code> attribute;
otherwise false.</p></li>
<li><p>Let <var>serializable</var> be true if <var>templateStartTag</var> has a <code
data-x="attr-template-shadowrootserializable">shadowrootserializable</code> attribute;
otherwise false.</p></li>

<li><p>If <var>declarative shadow host element</var> is a <span>shadow host</span>, then
<span>insert an element at the adjusted insertion location</span> with
<var>template</var>.</p></li>
<li><p>Let <var>delegatesFocus</var> be true if <var>templateStartTag</var> has a <code
data-x="attr-template-shadowrootdelegatesfocus">shadowrootdelegatesfocus</code> attribute;
otherwise false.</p></li>

<li>
<p>Otherwise:
<li><p>If <var>declarativeShadowHostElement</var> is a <span>shadow host</span>, then
<span>insert an element at the adjusted insertion location</span> with
<var>template</var>.</p></li>

<ol>
<li>
<p><span data-x="concept-attach-a-shadow-root">Attach a shadow root</span> with
<var>declarative shadow host element</var>, <var>mode</var>, <var>clonable</var>,
<var>serializable</var>, <var>delegatesFocus</var>, "<code data-x="">named</code>", and
<var>registry</var>.</p>

<p>If an exception is thrown, then catch it and:</p>
<p>Otherwise:</p>

<ol>
<li><p><span>Insert an element at the adjusted insertion location</span> with
<var>template</var>.</p></li>
<li><p>Let <var>registry</var> be <var>declarativeShadowHostElement</var>'s <span
data-x="element-custom-element-registry">custom element registry</span>.</p></li>

<li><p>The user agent may report an error to the developer console.</p></li>
<li><p>If <var>templateStartTag</var> has a <code
data-x="attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry</code>
attribute, then set <var>registry</var> to null.</p></li>

<li><p>Return.</p></li>
</ol>
</li>
<li>
<p><span data-x="concept-attach-a-shadow-root">Attach a shadow root</span> with
<var>declarativeShadowHostElement</var>, <var>mode</var>, <var>clonable</var>,
<var>serializable</var>, <var>delegatesFocus</var>, "<code data-x="">named</code>", and
<var>registry</var>.</p>

<p>If an exception is thrown, then catch it and:</p>

<li><p>Let <var>shadow</var> be <var>declarative shadow host element</var>'s
<span data-x="concept-element-shadow-root">shadow root</span>.</p></li>
<ol>
<li><p><span>Insert an element at the adjusted insertion location</span> with
<var>template</var>.</p></li>

<li><p>The user agent may report an error to the developer console.</p></li>

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

<li><p>Set <var>shadow</var>'s
<span data-x="concept-shadow-root-declarative">declarative</span> to true.</p></li>
<li><p>Let <var>shadow</var> be <var>declarativeShadowHostElement</var>'s <span
data-x="concept-element-shadow-root">shadow root</span>.</p></li>

<li><p>Set <span>template</span>'s <span>template contents</span> property to
<var>shadow</var>.</p></li>
<li><p>Set <var>shadow</var>'s <span
data-x="concept-shadow-root-declarative">declarative</span> to true.</p></li>

<li><p>Set <var>shadow</var>'s <span>available to element internals</span> to true.</p></li>
<li><p>Set <span>template</span>'s <span>template contents</span> property to
<var>shadow</var>.</p></li>

<li><p>If <var>template start tag</var> has a <code
data-x="attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry</code>
attribute, then set <var>shadow</var>'s <span>keep custom element registry null</span> to
true.</p></li>
<li><p>Set <var>shadow</var>'s <span>available to element internals</span> to
true.</p></li>

<li><p>If <var>templateStartTag</var> has a <code
data-x="attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry</code>
attribute, then set <var>shadow</var>'s <span>keep custom element registry null</span> to
true.</p></li>
</ol>
</li>
</ol>
</li>
</ol>
Expand Down