Skip to content

Commit

Permalink
Allow not executing scripts inserted by document.write()
Browse files Browse the repository at this point in the history
This allows user agents to experiment with better heuristics for not executing such scripts, as per WICG/interventions#17.
  • Loading branch information
domenic authored Jul 13, 2017
1 parent 508cf2d commit 15b258d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -57437,7 +57437,8 @@ interface <dfn>HTMLScriptElement</dfn> : <span>HTMLElement</span> {
</div>

<p class="note">When inserted using the <code data-x="dom-document-write">document.write()</code>
method, <code>script</code> elements execute (typically blocking further script execution or HTML parsing), but when inserted using
method, <code>script</code> elements <a href="#document-written-scripts-intervention">usually</a>
execute (typically blocking further script execution or HTML parsing). When inserted using the
<code data-x="dom-innerHTML">innerHTML</code> and <code data-x="dom-outerHTML">outerHTML</code>
attributes, they do not execute at all.</p>

Expand Down Expand Up @@ -90625,8 +90626,10 @@ document.body.appendChild(frame)</pre>
"<code data-x="">&lt;plaintext&gt;</code>" or "<code data-x="">&lt;!--</code>"). In other cases,
the call can clear the current page first, as if <code
data-x="dom-document-open">document.open()</code> had been called. In yet more cases, the method
is simply ignored, or throws an exception. To make matters worse, the exact behavior of this
method can in some cases be dependent on network latency<!--
is simply ignored, or throws an exception. Users agents are <a
href="#document-written-scripts-intervention">explicitly allowed to avoid executing
<code>script</code> elements inserted via this method</a>. And to make matters even worse, the
exact behavior of this method can in some cases be dependent on network latency<!--

Namely, in the following case:

Expand Down Expand Up @@ -105465,6 +105468,14 @@ document.body.appendChild(text);
algorithm</span>, then mark the <code>script</code> element as <span>"already started"</span>.
(<span>fragment case</span>)</p></li>

<li id="document-written-scripts-intervention"><p>If the parser was invoked via the <code
data-x="dom-document-write">document.write()</code> or <code
data-x="dom-document-writeln">document.writeln()</code> methods, then optionally mark the
<code>script</code> element as <span>"already started"</span>. (For example, the user agent
might use this clause to prevent execution of <span data-x="origin">cross-origin</span> scripts
inserted via <code data-x="dom-document-write">document.write()</code> under slow network
conditions, or when the page has already taken a long time to load.)</p></li>

<li><p>Insert the newly created element at the <var>adjusted insertion
location</var>.</p></li>

Expand Down Expand Up @@ -120817,6 +120828,7 @@ INSERT INTERFACES HERE
Keith Yeung,
Kelly Ford,
Kelly Norton,
Kenji Baheux,
Kevin Benson,
Kevin Cole,
Kevin Gadd,
Expand Down Expand Up @@ -121089,6 +121101,7 @@ INSERT INTERFACES HERE
Shiino Yuki, <!-- yuki3 on GitHub -->
贺师俊 (HE Shi-Jun), <!-- hax on GitHub -->
Shiki Okasaka,
Shivani Sharma,
Shubheksha Jalan,
Sierk Bornemann,
Sigbj&oslash;rn Finne,
Expand Down

0 comments on commit 15b258d

Please sign in to comment.