Skip to content

Remove connectedness check in script post-connection steps #11543

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
38 changes: 5 additions & 33 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -64358,36 +64358,6 @@ o............A....e
<var>insertedNode</var>, are:</p>

<ol>
<li>
<p>If <var>insertedNode</var> is not <span>connected</span>, then return.</p>

<div class="example">
<p>This can happen in the case where an earlier-inserted <code>script</code> removes a
later-inserted <code>script</code>. For instance:</p>

<pre><code class="html">&lt;script>
const script1 = document.createElement('script');
script1.innerText = `
document.querySelector('#script2').remove();
`;

const script2 = document.createElement('script');
script2.id = 'script2';
script2.textContent = `console.log('script#2 running')`;

document.body.append(script1, script2);
&lt;/script></code></pre>

<p>Nothing is printed to the console in this example. By the time the <span>HTML element
post-connection steps</span> run for the first <code>script</code> that was atomically inserted
by <code data-x="dom-Node-append">append()</code>, it can observe that the second
<code>script</code> is already <span>connected</span> to the DOM. It removes the second
<code>script</code>, so that by the time <em>its</em> <span>HTML element post-connection
steps</span> run, it is no longer <span>connected</span>, and does not get <span
data-x="prepare the script element">prepared</span>.</p>
</div>
</li>

<li><p>If <var>insertedNode</var> is <span>parser-inserted</span>, then return.</p></li>

<li><p><span>Prepare the script element</span> given <var>insertedNode</var>.</p></li>
Expand All @@ -64396,6 +64366,8 @@ document.body.append(script1, script2);
<p>The <code>script</code> <span>children changed steps</span> are:</p>

<ol>
<li><p>If the <code>script</code> element is not <span>connected</span>, then return.</p></li>

<li><p>Run the <code>script</code> <span>HTML element post-connection steps</span>, given the
<code>script</code> element.</p></li>
</ol>
Expand Down Expand Up @@ -64449,9 +64421,9 @@ document.body.append(script1, script2);
<ol>
<li><p>If <var>namespace</var> is not null, then return.</p></li>

<li><p>If <var>localName</var> is <code data-x="attr-script-src">src</code>, then run the
<code>script</code> <span>HTML element post-connection steps</span>, given
<var>element</var>.</p></li>
<li><p>If <var>localName</var> is <code data-x="attr-script-src">src</code> and
<var>element</var> is <span>connected</span>, then run the <code>script</code> <span>HTML element
post-connection steps</span>, given <var>element</var>.</p></li>
</ol>

<p id="prepare-a-script">To <dfn>prepare the script element</dfn> given a <code>script</code>
Expand Down