@@ -64313,14 +64313,17 @@ o............A....e
64313
64313
<var>insertedNode</var>, are:</p>
64314
64314
64315
64315
<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>
64318
64317
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>
64322
64320
64323
- <pre><code class="html"><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"><script>
64324
64327
const script1 = document.createElement('script');
64325
64328
script1.innerText = `
64326
64329
document.querySelector('#script2').remove();
@@ -64333,20 +64336,14 @@ script2.textContent = `console.log('script#2 running')`;
64333
64336
document.body.append(script1, script2);
64334
64337
</script></code></pre>
64335
64338
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>
64350
64347
64351
64348
<p>The <code>script</code> <span>HTML element removing steps</span> given <var>removedNode</var>
64352
64349
are:</p>
@@ -64373,6 +64370,8 @@ document.body.append(script1, script2);
64373
64370
are:</p>
64374
64371
64375
64372
<ol>
64373
+ <li><p>If the <code>script</code> element is not <span>connected</span>, then return.</p></li>
64374
+
64376
64375
<li><p>Run the <code>script</code> <span>HTML element post-connection steps</span>, given
64377
64376
<var>changedNode</var>.</p></li>
64378
64377
</ol>
@@ -64426,9 +64425,9 @@ document.body.append(script1, script2);
64426
64425
<ol>
64427
64426
<li><p>If <var>namespace</var> is not null, then return.</p></li>
64428
64427
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>
64432
64431
</ol>
64433
64432
64434
64433
<p id="prepare-a-script">To <dfn>prepare the script element</dfn> given a <code>script</code>
0 commit comments