Skip to content

Commit

Permalink
currentScript needs to point to removed script elements
Browse files Browse the repository at this point in the history
To avoid leaking shadow trees we added an “in a document” check in
caf203f. This turned out to not be
web compatible. So instead, we check whether the script element is in
a shadow tree. Ideally that is novel enough to not cause any
compatibility issues.

Fixes #1161.
  • Loading branch information
annevk authored and domenic committed May 2, 2016
1 parent 6021031 commit 3dc7638
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3100,6 +3100,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d

<li><dfn data-noexport="" data-x-href="https://dom.spec.whatwg.org/#concept-node-document">node document</dfn> concept</li>
<li><dfn data-noexport="" data-x="concept-DocumentFragment-host" data-x-href="https://dom.spec.whatwg.org/#concept-documentfragment-host">host</dfn> concept</li>
<li><dfn data-noexport="" data-x-href="https://dom.spec.whatwg.org/#concept-shadow-root">shadow root</dfn> concept</li>

<li><dfn data-noexport="" data-x-href="https://dom.spec.whatwg.org/#interface-htmlcollection"><code>HTMLCollection</code></dfn> interface</li>
<li><dfn data-noexport="" data-x="dom-HTMLCollection-length" data-x-href="https://dom.spec.whatwg.org/#dom-htmlcollection-length"><code>HTMLCollection.length</code></dfn> attribute</li>
Expand Down Expand Up @@ -59122,10 +59123,17 @@ o............A....e
<dt>"<code data-x="">classic</code>"</dt>
<dd>
<ol>
<li><p>If the <code>script</code> element is <span>in a document</span>, then 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. Otherwise, set it to null.</p></li>
<li>
<p>If the <code>script</code> element's <span>root</span> is <em>not</em> a <span>shadow
root</span>, then 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. Otherwise, set it to null.</p>

<p class="note">This does not use the <span>in a document</span> check, as the
<code>script</code> element could have been removed from the document prior to execution,
and in that scenario <code data-x="dom-document-currentScript">currentScript</code> still
needs to point to it.</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>
Expand Down Expand Up @@ -67081,7 +67089,7 @@ console.log(plasticButton2.getAttribute("is")); // will output "plastic-button"<
is truly one-time will need a guard to prevent it from running twice.</p></li>

<li><p>In general, the constructor should be used to set up initial state and default values, and
to set up event listeners and possibly a shadow root.</p></li>
to set up event listeners and possibly a <span>shadow root</span>.</p></li>
</ul>

<p>Several of these requirements are checked during <span data-x="create an element">element
Expand Down

0 comments on commit 3dc7638

Please sign in to comment.