Skip to content

Commit

Permalink
Make module scripts modify less global script state
Browse files Browse the repository at this point in the history
They no longer set document.currentScript, or fire beforescriptexecute
and afterscriptexecute events.

Closes #997. See #1013 for a future alternative to
document.currentScript, and #943 for more discussion of the events.
  • Loading branch information
domenic committed Apr 11, 2016
1 parent 83f4ca9 commit 33ea3ae
Showing 1 changed file with 29 additions and 42 deletions.
71 changes: 29 additions & 42 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -9037,12 +9037,14 @@ partial /*sealed*/ interface <dfn>Document</dfn> {
<dd>

<p>Returns the <code>script</code> element, or the <span>SVG <code>script</code></span> element,
that is currently executing. In the case of reentrant script execution, returns the one that
most recently started executing amongst those that have not yet finished executing.</p>
that is currently executing, as long as the element represents a <span>classic script</span>.
In the case of reentrant script execution, returns the one that most recently started executing
amongst those that have not yet finished executing.</p>

<p>Returns null if the <code>Document</code> is not currently executing a <code>script</code>
or <span>SVG <code>script</code></span> element (e.g., because the running script is an event
handler, or a timeout).</p>
handler, or a timeout), or if the currently executing <code>script</code> or <span>SVG
<code>script</code></span> element represents a <span>module script</span>.</p>

</dd>

Expand All @@ -9051,9 +9053,9 @@ partial /*sealed*/ interface <dfn>Document</dfn> {
<div w-nodev>

<p>The <dfn><code data-x="dom-document-currentScript">currentScript</code></dfn> attribute, on
getting, must return the value to which it was most recently initialised. When the
<code>Document</code> is created, the <code
data-x="dom-document-currentScript">currentScript</code> must be initialised to null.</p>
getting, must return the value to which it was most recently set. When the <code>Document</code>
is created, the <code data-x="dom-document-currentScript">currentScript</code> must be
initialised to null.</p>

</div>

Expand Down Expand Up @@ -58882,7 +58884,8 @@ o............A....e

<li>

<p><span>Fire a simple event</span> named <code
<p>If <span data-x="concept-script-type">the script's type</span> is "<code
data-x="">classic</code>", <span>fire a simple event</span> named <code
data-x="event-beforescriptexecute">beforescriptexecute</code> that bubbles and is cancelable
at the <code>script</code> element.</p>

Expand All @@ -58900,39 +58903,30 @@ o............A....e

</li>

<li>

<p>Let <var>old script element</var> be the value to which the <code>script</code>
element's <span>node document</span>'s <code
data-x="dom-document-currentScript">currentScript</code> object was most recently
initialised.</p>

</li>

<li>

<p>Initialise the <code>script</code> element's <span>node document</span>'s <code
data-x="dom-document-currentScript">currentScript</code> object to the <code>script</code>
element.</p>

</li>

<li>

<p>Let <var>settings object</var> be the <span>environment settings object</span> of the
<code>script</code> element's <span>node document</span>'s <code>Window</code> object.</p>

</li>

<li>

<p>Switch on <span data-x="concept-script-type">the script's type</span>:</p>

<dl class="switch">
<dt>"<code data-x="">classic</code>"</dt>
<dd>
<p><span data-x="run a classic script">Run the classic script</span> given by <span
data-x="concept-script-script">the script's script</span>.</p>
<ol>
<li><p>Let <var>old script element</var> be the value to which the <code>script</code>
element's <span>node document</span>'s <code
data-x="dom-document-currentScript">currentScript</code> object was most recently
set.</p></li>

<li><p>Set the <code>script</code> element's <span>node document</span>'s <code
data-x="dom-document-currentScript">currentScript</code> attribute to the
<code>script</code> element.</p></li>

<li><p><span data-x="run a classic script">Run the classic script</span> given by <span
data-x="concept-script-script">the script's script</span>.</p></li>

<li><p>Set the <code>script</code> element's <span>node document</span>'s <code
data-x="dom-document-currentScript">currentScript</code> attribute to <var>old script
element</var>.</p></li>
</ol>
</dd>

<dt>"<code data-x="">module</code>"</dt>
Expand All @@ -58944,14 +58938,6 @@ o............A....e

</li>

<li>

<p>Initialise the <code>script</code> element's <span>node document</span>'s <code
data-x="dom-document-currentScript">currentScript</code> object to <var>old script
element</var>.</p>

</li>

<li>

<p>Decrement the <span>ignore-destructive-writes counter</span> of <var>neutralised doc</var>, if it was incremented in the earlier step.</p>
Expand All @@ -58960,7 +58946,8 @@ o............A....e

<li>

<p><span>Fire a simple event</span> named <code
<p>If <span data-x="concept-script-type">the script's type</span> is "<code
data-x="">classic</code>", <span>fire a simple event</span> named <code
data-x="event-afterscriptexecute">afterscriptexecute</code> that bubbles (but is not
cancelable) at the <code>script</code> element.</p>

Expand Down

0 comments on commit 33ea3ae

Please sign in to comment.