Skip to content

Commit

Permalink
Execute <script> in shadow trees
Browse files Browse the repository at this point in the history
This makes <script> elements work when used in shadow trees. The
beforescriptexecute and afterscriptexecute events won’t work, since
they are already disabled for modules and only makes sense together
with currentScript, which cannot be made to work for shadow scripts.
See #1013 for details.

Fixes #762.
  • Loading branch information
annevk committed Apr 22, 2016
1 parent 4d08da6 commit 22b8379
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,12 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
data-x="concept-node-remove-ext">removing steps</span> are invoked with it as argument and it is
now no longer <span>in a document</span>.</p>

<p>A <dfn>node is connected</dfn> when the <span data-x="concept-node-insert-ext">insertion
steps</span> are invoked with it as argument and it is now <span>in a shadow-including
document</span>. Analogously, a <dfn>node is disconnected</dfn> when the <span
data-x="concept-node-remove-ext">removing steps</span> are invoked with it as argument and it is
now no longer <span>in a shadow-including document</span>.</p>


<h4>Scripting</h4>

Expand Down Expand Up @@ -58554,23 +58560,21 @@ o............A....e
<hr>

<p>When a <code>script</code> element that is not marked as being <span>"parser-inserted"</span>
experiences one of the events listed in the following list, the user agent must <span>immediately</span>
<span data-x="prepare a script">prepare</span> the <code>script</code> element:</p>
experiences one of the events listed in the following list, the user agent must
<span>immediately</span> <span data-x="prepare a script">prepare</span> the <code>script</code>
element:</p>

<ul>

<li>The <code>script</code> element gets <span data-x="node is inserted into a document">inserted
into a document</span>, at the time the <span data-x="nodes are inserted">node is inserted</span>
according to the DOM, after any other <code>script</code> elements inserted at the same time that
are earlier in the <code>Document</code> in <span>tree order</span>.</li>
<li>The <code>script</code> element gets <span data-x="node is connected">connected</span>.</li>

<li>The <code>script</code> element is <span>in a <code>Document</code></span> and a node or
<li>The <code>script</code> element is <span>in a shadow-including document</span> and a node or
document fragment is <span data-x="nodes are inserted">inserted</span> into the
<code>script</code> element, after any <code>script</code> elements <span data-x="nodes are
inserted">inserted</span> at that time.</li>

<li>The <code>script</code> element is <span>in a <code>Document</code></span> and has a <code
data-x="attr-script-src">src</code> attribute set where previously the element had no such
<li>The <code>script</code> element is <span>in a shadow-including document</span> and has a
<code data-x="attr-script-src">src</code> attribute set where previously the element had no such
attribute.</li>

</ul>
Expand Down Expand Up @@ -59118,9 +59122,9 @@ o............A....e
<li>

<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>
data-x="">classic</code>" and the element is <span>in a document</span>, then <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>

<p>If the event is canceled, then abort these steps.</p>

Expand Down Expand Up @@ -59155,7 +59159,8 @@ o............A....e
<ol>
<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>
<code>script</code> element, if the <code>script</code> element is <span>in a
document</span>, and to null otherwise.</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 @@ -59193,9 +59198,9 @@ o............A....e
<li>

<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>
data-x="">classic</code>" and the element is <span>in a document</span>, then <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>

</li>

Expand All @@ -59208,6 +59213,7 @@ o............A....e

<p>Otherwise <span>queue a task</span> to <span>fire a simple event</span> named <code
data-x="event-load">load</code> at the <code>script</code> element.</p>
<!-- Shadow TODO: this event needs to be scoped -->

</li>

Expand Down

0 comments on commit 22b8379

Please sign in to comment.