Skip to content

Commit

Permalink
[giow] (1) Add document.currentScript, as implemented by Mozilla.
Browse files Browse the repository at this point in the history
Affected topics: DOM APIs, HTML

git-svn-id: http://svn.whatwg.org/webapps@7551 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Nov 29, 2012
1 parent 72d811f commit 96e0dcf
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
43 changes: 43 additions & 0 deletions complete.html
Expand Up @@ -9725,6 +9725,7 @@ <h3 id=documents><span class=secno>3.1 </span>Documents</h3>
NodeList <a href=#dom-document-getelementsbyname title=dom-document-getElementsByName>getElementsByName</a>(DOMString elementName);
NodeList <a href=#dom-document-getitems title=dom-document-getItems>getItems</a>(optional DOMString typeNames); // <a href=#microdata>microdata</a>
readonly attribute <a href=#domelementmap>DOMElementMap</a> <a href=#dom-document-csselementmap title=dom-document-cssElementMap>cssElementMap</a>;
readonly attribute <a href=#htmlscriptelement>HTMLScriptElement</a>? <a href=#dom-document-currentscript title=dom-document-currentScript>currentScript</a>;

// <a href=#dynamic-markup-insertion>dynamic markup insertion</a>
<a href=#document>Document</a> <a href=#dom-document-open title=dom-document-open>open</a>(optional DOMString type, optional DOMString replace);
Expand Down Expand Up @@ -10284,6 +10285,26 @@ <h4 id=dom-tree-accessors><span class=secno>3.1.4 </span><dfn>DOM tree accessors

</div>

<hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-document-currentScript><a href=#dom-document-currentscript>currentScript</a></code></dt>
<dd>

<p>Returns the <code><a href=#the-script-element>script</a></code> element that is currently executing. In the case of reentrant
<code><a href=#the-script-element>script</a></code> execution, returns the one that most recently started executing amongst
those that have not yet finished executing.</p>

<p>Returns null if the <code><a href=#document>Document</a></code> is not currently executing a <code><a href=#the-script-element>script</a></code>
element (e.g. because the running script is an event handler, or a timeout).</p>

</dd>

</dl><div class=impl>

<p>The <dfn id=dom-document-currentscript title=dom-document-currentScript><code>currentScript</code></dfn> attribute, on
getting, must return the value to which it was most recently initialized. When the
<code><a href=#document>Document</a></code> is created, the <code title=dom-document-currentScript><a href=#dom-document-currentscript>currentScript</a></code> must be initialized to null.</p>

</div>

<div class=impl>

<hr><p id=dom-document-namedItem-which>The <code><a href=#document>Document</a></code>
Expand Down Expand Up @@ -16755,6 +16776,21 @@ <h4 id=the-script-element><span class=secno>4.3.1 </span>The <dfn id=script><cod

</li>

<li>

<p>Let <var title="">old script element</var> be the value to which the
<code><a href=#document>Document</a></code> element's <code title=dom-document-currentScript><a href=#dom-document-currentscript>currentScript</a></code> object was most recently
initialized.</p>

</li>

<li>

<p>Initialize the <code><a href=#document>Document</a></code> element's <code title=dom-document-currentScript><a href=#dom-document-currentscript>currentScript</a></code> object to the <code><a href=#the-script-element>script</a></code>
element.</p>

</li>

<li>

<p><a href=#create-a-script-from-a-node title="create a script from a node">Create a
Expand All @@ -16772,6 +16808,13 @@ <h4 id=the-script-element><span class=secno>4.3.1 </span>The <dfn id=script><cod

</li>

<li>

<p>Initialize the <code><a href=#document>Document</a></code> element's <code title=dom-document-currentScript><a href=#dom-document-currentscript>currentScript</a></code> object to <var title="">old script
element</var>.</p>

</li>

<li>

<p>Decrement the <a href=#ignore-destructive-writes-counter>ignore-destructive-writes
Expand Down
43 changes: 43 additions & 0 deletions index
Expand Up @@ -9725,6 +9725,7 @@ partial /*sealed*/ interface <dfn id=document>Document</dfn> {
NodeList <a href=#dom-document-getelementsbyname title=dom-document-getElementsByName>getElementsByName</a>(DOMString elementName);
NodeList <a href=#dom-document-getitems title=dom-document-getItems>getItems</a>(optional DOMString typeNames); // <a href=#microdata>microdata</a>
readonly attribute <a href=#domelementmap>DOMElementMap</a> <a href=#dom-document-csselementmap title=dom-document-cssElementMap>cssElementMap</a>;
readonly attribute <a href=#htmlscriptelement>HTMLScriptElement</a>? <a href=#dom-document-currentscript title=dom-document-currentScript>currentScript</a>;

// <a href=#dynamic-markup-insertion>dynamic markup insertion</a>
<a href=#document>Document</a> <a href=#dom-document-open title=dom-document-open>open</a>(optional DOMString type, optional DOMString replace);
Expand Down Expand Up @@ -10284,6 +10285,26 @@ partial /*sealed*/ interface <dfn id=document>Document</dfn> {

</div>

<hr><dl class=domintro><dt><var title="">document</var> . <code title=dom-document-currentScript><a href=#dom-document-currentscript>currentScript</a></code></dt>
<dd>

<p>Returns the <code><a href=#the-script-element>script</a></code> element that is currently executing. In the case of reentrant
<code><a href=#the-script-element>script</a></code> execution, returns the one that most recently started executing amongst
those that have not yet finished executing.</p>

<p>Returns null if the <code><a href=#document>Document</a></code> is not currently executing a <code><a href=#the-script-element>script</a></code>
element (e.g. because the running script is an event handler, or a timeout).</p>

</dd>

</dl><div class=impl>

<p>The <dfn id=dom-document-currentscript title=dom-document-currentScript><code>currentScript</code></dfn> attribute, on
getting, must return the value to which it was most recently initialized. When the
<code><a href=#document>Document</a></code> is created, the <code title=dom-document-currentScript><a href=#dom-document-currentscript>currentScript</a></code> must be initialized to null.</p>

</div>

<div class=impl>

<hr><p id=dom-document-namedItem-which>The <code><a href=#document>Document</a></code>
Expand Down Expand Up @@ -16755,6 +16776,21 @@ c-end = "--&gt;"</pre>

</li>

<li>

<p>Let <var title="">old script element</var> be the value to which the
<code><a href=#document>Document</a></code> element's <code title=dom-document-currentScript><a href=#dom-document-currentscript>currentScript</a></code> object was most recently
initialized.</p>

</li>

<li>

<p>Initialize the <code><a href=#document>Document</a></code> element's <code title=dom-document-currentScript><a href=#dom-document-currentscript>currentScript</a></code> object to the <code><a href=#the-script-element>script</a></code>
element.</p>

</li>

<li>

<p><a href=#create-a-script-from-a-node title="create a script from a node">Create a
Expand All @@ -16772,6 +16808,13 @@ c-end = "--&gt;"</pre>

</li>

<li>

<p>Initialize the <code><a href=#document>Document</a></code> element's <code title=dom-document-currentScript><a href=#dom-document-currentscript>currentScript</a></code> object to <var title="">old script
element</var>.</p>

</li>

<li>

<p>Decrement the <a href=#ignore-destructive-writes-counter>ignore-destructive-writes
Expand Down
53 changes: 53 additions & 0 deletions source
Expand Up @@ -9678,6 +9678,7 @@ partial /*sealed*/ interface <dfn>Document</dfn> {
NodeList <span title="dom-document-getElementsByName">getElementsByName</span>(DOMString elementName);
NodeList <span title="dom-document-getItems">getItems</span>(optional DOMString typeNames); // <span>microdata</span>
readonly attribute <span>DOMElementMap</span> <span title="dom-document-cssElementMap">cssElementMap</span>;
readonly attribute <span>HTMLScriptElement</span>? <span title="dom-document-currentScript">currentScript</span>;

// <span>dynamic markup insertion</span>
<span>Document</span> <span title="dom-document-open">open</span>(optional DOMString type, optional DOMString replace);
Expand Down Expand Up @@ -10355,6 +10356,33 @@ partial /*sealed*/ interface <dfn>Document</dfn> {

</div>

<hr>

<dl class="domintro">

<dt><var title="">document</var> . <code title="dom-document-currentScript">currentScript</code></dt>
<dd>

<p>Returns the <code>script</code> element that is currently executing. In the case of reentrant
<code>script</code> 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>
element (e.g. because the running script is an event handler, or a timeout).</p>

</dd>

</dl>

<div class="impl">

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

</div>

<div class="impl">

<hr>
Expand Down Expand Up @@ -17705,6 +17733,23 @@ c-end = "-->"</pre>

</li>

<li>

<p>Let <var title="">old script element</var> be the value to which the
<code>Document</code> element's <code
title="dom-document-currentScript">currentScript</code> object was most recently
initialized.</p>

</li>

<li>

<p>Initialize the <code>Document</code> element's <code
title="dom-document-currentScript">currentScript</code> object to the <code>script</code>
element.</p>

</li>

<li>

<p><span title="create a script from a node">Create a
Expand All @@ -17723,6 +17768,14 @@ c-end = "-->"</pre>

</li>

<li>

<p>Initialize the <code>Document</code> element's <code
title="dom-document-currentScript">currentScript</code> object to <var title="">old script
element</var>.</p>

</li>

<li>

<p>Decrement the <span>ignore-destructive-writes
Expand Down

0 comments on commit 96e0dcf

Please sign in to comment.