8000 Remove connectedness check in script post-connection steps · whatwg/html@905384d · GitHub
[go: up one dir, main page]

Skip to content

Commit 905384d

Browse files
authored
Remove connectedness check in script post-connection steps
1 parent 07cc083 commit 905384d

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

source

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64313,14 +64313,17 @@ o............A....e
6431364313
<var>insertedNode</var>, are:</p>
6431464314

6431564315
<ol>
64316-
<li>
64317-
<p>If <var>insertedNode</var> is not <span>connected</span>, then return.</p>
64316+
<li><p>If <var>insertedNode</var> is <span>parser-inserted</span>, then return.</p></li>
6431864317

64319-
<div class="example">
64320-
<p>This can happen in the case where an earlier-inserted <code>script</code> removes a
64321-
later-inserted <code>script</code>. For instance:</p>
64318+
<li><p><span>Prepare the script element</span> given <var>insertedNode</var>.</p></li>
64319+
</ol>
6432264320

64323-
<pre><code class="html">&lt;script>
64321+
<div class="example">
64322+
<p>The <span>HTML element post-connection steps</span> only run when the inserted element is
64323+
still <span>connected</span>, which protects against cases where an earlier-inserted
64324+
<code>script</code> removes a later-inserted <code>script</code>. For instance:</p>
64325+
64326+
<pre><code class="html">&lt;script>
6432464327
const script1 = document.createElement('script');
6432564328
script1.innerText = `
6432664329
document.querySelector('#script2').remove();
@@ -64333,20 +64336,14 @@ script2.textContent = `console.log('script#2 running')`;
6433364336
document.body.append(script1, script2);
6433464337
&lt;/script></code></pre>
6433564338

64336-
<p>Nothing is printed to the console in this example. By the time the <span>HTML element
64337-
post-connection steps</span> run for the first <code>script</code> that was atomically inserted
64338-
by <code data-x="dom-Node-append">append()</code>, it can observe that the second
64339-
<code>script</code> is already <span>connected</span> to the DOM. It removes the second
64340-
<code>script</code>, so that by the time <em>its</em> <span>HTML element post-connection
64341-
steps</span> run, it is no longer <span>connected</span>, and does not get <span
64342-
data-x="prepare the script element">prepared</span>.</p>
64343-
</div>
64344-
</li>
64345-
64346-
<li><p>If <var>insertedNode</var> is <span>parser-inserted</span>, then return.</p></li>
64347-
64348-
<li><p><span>Prepare the script element</span> given <var>insertedNode</var>.</p></li>
64349-
</ol>
64339+
<p>Nothing is printed to the console in this example. By the time the <span>HTML element
64340+
post-connection steps</span> run for the first <code>script</code> that was atomically inserted
64341+
by <code data-x="dom-Node-append">append()</code>, it can observe that the second
64342+
<code>script</code> is already <span>connected</span> to the DOM, and it removes it from the DOM.
64343+
Because the second <code>script</code> is no longer <span>connected</span>, its <span>HTML
64344+
element post-connection steps</span> do not run, and it does not get <span data-x="prepare the
64345+
script element">prepared</span>.</p>
64346+
</div>
6435064347

6435164348
<p>The <code>script</code> <span>HTML element removing steps</span> given <var>removedNode</var>
6435264349
are:</p>
@@ -64373,6 +64370,8 @@ document.body.append(script1, script2);
6437364370
are:</p>
6437464371

6437564372
<ol>
64373+
<li><p>If the <code>script</code> element is not <span>connected</span>, then return.</p></li>
64374+
6437664375
<li><p>Run the <code>script</code> <span>HTML element post-connection steps</span>, given
6437764376
<var>changedNode</var>.</p></li>
6437864377
</ol>
@@ -64426,9 +64425,9 @@ document.body.append(script1, script2);
6442664425
<ol>
6442764426
<li><p>If <var>namespace</var> is not null, then return.</p></li>
6442864427

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

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

0 commit comments

Comments
 (0)
0