Skip to content

Commit 33ea3ae

Browse files
committed
Make module scripts modify less global script state
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.
1 parent 83f4ca9 commit 33ea3ae

File tree

1 file changed

+29
-42
lines changed

1 file changed

+29
-42
lines changed

source

+29-42
Original file line numberDiff line numberDiff line change
@@ -9037,12 +9037,14 @@ partial /*sealed*/ interface <dfn>Document</dfn> {
90379037
<dd>
90389038

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

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

90479049
</dd>
90489050

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

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

90589060
</div>
90599061

@@ -58882,7 +58884,8 @@ o............A....e
5888258884

5888358885
<li>
5888458886

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

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

5890158904
</li>
5890258905

58903-
<li>
58904-
58905-
<p>Let <var>old script element</var> be the value to which the <code>script</code>
58906-
element's <span>node document</span>'s <code
58907-
data-x="dom-document-currentScript">currentScript</code> object was most recently
58908-
initialised.</p>
58909-
58910-
</li>
58911-
58912-
<li>
58913-
58914-
<p>Initialise the <code>script</code> element's <span>node document</span>'s <code
58915-
data-x="dom-document-currentScript">currentScript</code> object to the <code>script</code>
58916-
element.</p>
58917-
58918-
</li>
58919-
58920-
<li>
58921-
58922-
<p>Let <var>settings object</var> be the <span>environment settings object</span> of the
58923-
<code>script</code> element's <span>node document</span>'s <code>Window</code> object.</p>
58924-
58925-
</li>
58926-
5892758906
<li>
5892858907

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

5893158910
<dl class="switch">
5893258911
<dt>"<code data-x="">classic</code>"</dt>
5893358912
<dd>
58934-
<p><span data-x="run a classic script">Run the classic script</span> given by <span
58935-
data-x="concept-script-script">the script's script</span>.</p>
58913+
<ol>
58914+
<li><p>Let <var>old script element</var> be the value to which the <code>script</code>
58915+
element's <span>node document</span>'s <code
58916+
data-x="dom-document-currentScript">currentScript</code> object was most recently
58917+
set.</p></li>
58918+
58919+
<li><p>Set the <code>script</code> element's <span>node document</span>'s <code
58920+
data-x="dom-document-currentScript">currentScript</code> attribute to the
58921+
<code>script</code> element.</p></li>
58922+
58923+
<li><p><span data-x="run a classic script">Run the classic script</span> given by <span
58924+
data-x="concept-script-script">the script's script</span>.</p></li>
58925+
58926+
<li><p>Set the <code>script</code> element's <span>node document</span>'s <code
58927+
data-x="dom-document-currentScript">currentScript</code> attribute to <var>old script
58928+
element</var>.</p></li>
58929+
</ol>
5893658930
</dd>
5893758931

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

5894558939
</li>
5894658940

58947-
<li>
58948-
58949-
<p>Initialise the <code>script</code> element's <span>node document</span>'s <code
58950-
data-x="dom-document-currentScript">currentScript</code> object to <var>old script
58951-
element</var>.</p>
58952-
58953-
</li>
58954-
5895558941
<li>
5895658942

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

5896158947
<li>
5896258948

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

0 commit comments

Comments
 (0)