Permalink
Browse files

[agiow] (0) Make script-inserted external scripts that have .async=fa…

…lse execute in the insertion order, default to true

Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=11295

git-svn-id: http://svn.whatwg.org/webapps@5817 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
1 parent 8abfab6 commit 9869b028293a311a23eb5603a0f45d5d7d89f029 @Hixie Hixie committed Feb 3, 2011
Showing with 327 additions and 66 deletions.
  1. +107 −22 complete.html
  2. +107 −22 index
  3. +113 −22 source
View
@@ -239,7 +239,7 @@
<header class=head id=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1>Web Applications 1.0</h1>
- <h2 class="no-num no-toc">Living Standard &mdash; Last Updated 2 February 2011</h2>
+ <h2 class="no-num no-toc">Living Standard &mdash; Last Updated 3 February 2011</h2>
</hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
@@ -14883,7 +14883,17 @@ <h4 id=script><span class=secno>4.3.1 </span>The <dfn><code>script</code></dfn>
elements they insert and affects the processing of those
elements.</p>
- <p>The third is a flag indicating whether or not the script block is
+ <p>The third is a flag indicating whether the element will
+ <dfn id=force-async>"force-async"</dfn>. Initially, <code><a href=#script>script</a></code> elements
+ must have this flag set. It is unset by the <a href=#html-parser>HTML parser</a>
+ and the <a href=#xml-parser>XML parser</a> on <code><a href=#script>script</a></code> elements they
+ insert. In addition, whenever a <code><a href=#script>script</a></code> element whose
+ <a href=#force-async>"force-async"</a> flag is set has a <code title=attr-script-async><a href=#attr-script-async>async</a></code> content attribute added, the
+ element's <a href=#force-async>"force-async"</a> flag must be unset.</p> <!--
+ there's no need to unset it when the attribute is removed since you
+ can't have the attribute and the flag set at once. -->
+
+ <p>The fourth is a flag indicating whether or not the script block is
<dfn id=ready-to-be-parser-executed>"ready to be parser-executed"</dfn>. Initially,
<code><a href=#script>script</a></code> elements must have this flag unset (script
blocks, when created, are not "ready to be parser-executed"). This
@@ -14942,6 +14952,21 @@ <h4 id=script><span class=secno>4.3.1 </span>The <dfn><code>script</code></dfn>
</li>
+ <li>
+
+ <p>If <var title="">was-parser-inserted</var> is true and the
+ element does not have an <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute, then set the
+ element's <a href=#force-async>"force-async"</a> flag to true.</p>
+
+ <p class=note>This is done so that if a parser-inserted
+ <code><a href=#script>script</a></code> element fails to run when the parser tries to
+ run it, but it is later executed after a script dynamically
+ updates it, it will execute asynchronously even if the
+ <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute isn't
+ set.</p>
+
+ </li>
+
<li id=script-processing-empty>
<p>If the element has no <code title=attr-script-src><a href=#attr-script-src>src</a></code>
@@ -15001,17 +15026,18 @@ <h4 id=script><span class=secno>4.3.1 </span>The <dfn><code>script</code></dfn>
</li>
- <li id=script-processing-start>
+ <li>
- <p>The user agent must set the element's <a href=#already-started>"already
- started"</a> flag.</p>
+ <p>If <var title="">was-parser-inserted</var> is true, then flag
+ the element as <a href=#parser-inserted>"parser-inserted"</a> again, and set the
+ element's <a href=#force-async>"force-async"</a> flag to false.</p>
</li>
- <li>
+ <li id=script-processing-start>
- <p>If <var title="">was-parser-inserted</var> is true, then flag
- the element as <a href=#parser-inserted>"parser-inserted"</a> again.</p>
+ <p>The user agent must set the element's <a href=#already-started>"already
+ started"</a> flag.</p>
</li>
@@ -15097,6 +15123,9 @@ <h4 id=script><span class=secno>4.3.1 </span>The <dfn><code>script</code></dfn>
</li>
+ <!-- at this point if the element is "parser-inserted" then we know
+ it is not "force-async". -->
+
<li>
<p>Then, the first of the following options that describes the
@@ -15167,6 +15196,45 @@ <h4 id=script><span class=secno>4.3.1 </span>The <dfn><code>script</code></dfn>
</dd>
+ <dt id=script-processing-src-sync>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute, does not have an
+ <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute, and does
+ not have the <a href=#force-async>"force-async"</a> flag set</dt>
+
+ <dd>
+
+ <p>The element must be added to the end of the <dfn id=list-of-scripts-that-will-execute-in-order-as-soon-as-possible>list of
+ scripts that will execute in order as soon as possible</dfn>
+ associated with the <code><a href=#document>Document</a></code> of the
+ <code><a href=#script>script</a></code> element at the time the <a href=#running-a-script>running a
+ script</a> algorithm started.</p>
+
+ <p>The <a href=#concept-task title=concept-task>task</a> that the
+ <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task
+ queue</a> once the <a href=#fetch title=fetch>fetching
+ algorithm</a> has completed must run the following steps:</p>
+
+ <ol><li><p>If the element is not now the first element in the
+ <a href=#list-of-scripts-that-will-execute-in-order-as-soon-as-possible>list of scripts that will execute in order as soon as
+ possible</a> to which it was added above, then mark the
+ element as ready but abort these steps without executing the
+ script yet.</li>
+
+ <li><p><i>Execution</i>: <a href=#executing-a-script-block title="executing a script
+ block">Execute the script block</a> corresponding to the
+ first script element in this <a href=#list-of-scripts-that-will-execute-in-order-as-soon-as-possible>list of scripts that will
+ execute in order as soon as possible</a>.</li>
+
+ <li><p>Remove the first element from this <a href=#list-of-scripts-that-will-execute-in-order-as-soon-as-possible>list of scripts
+ that will execute in order as soon as possible</a>.</li>
+
+ <li><p>If this <a href=#list-of-scripts-that-will-execute-in-order-as-soon-as-possible>list of scripts that will execute in order
+ as soon as possible</a> is still not empty and the first
+ entry has already been marked as ready, then jump back to the
+ step labeled <i>execution</i>.</li>
+
+ </ol></dd>
+
+
<dt id=script-processing-src>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute</dt>
<dd>
@@ -15392,10 +15460,22 @@ <h4 id=script><span class=secno>4.3.1 </span>The <dfn><code>script</code></dfn>
</ol></dd>
- </dl><p>The IDL attributes <dfn id=dom-script-src title=dom-script-src><code>src</code></dfn>, <dfn id=dom-script-type title=dom-script-type><code>type</code></dfn>, <dfn id=dom-script-charset title=dom-script-charset><code>charset</code></dfn>, <dfn id=dom-script-async title=dom-script-async><code>async</code></dfn>, and <dfn id=dom-script-defer title=dom-script-defer><code>defer</code></dfn>, each must
+ </dl><p>The IDL attributes <dfn id=dom-script-src title=dom-script-src><code>src</code></dfn>, <dfn id=dom-script-type title=dom-script-type><code>type</code></dfn>, <dfn id=dom-script-charset title=dom-script-charset><code>charset</code></dfn>, and <dfn id=dom-script-defer title=dom-script-defer><code>defer</code></dfn>, each must
<a href=#reflect>reflect</a> the respective content attributes of the same
name.</p>
+ <p>The <dfn id=dom-script-async title=dom-script-async><code>async</code></dfn> IDL
+ attribute controls whether the element will execute asynchronously
+ or not. If the element's <a href=#force-async>"force-async"</a> flag is set,
+ then, on getting, the <code title=dom-script-async><a href=#dom-script-async>async</a></code>
+ IDL attribute must return true, and on setting, the
+ <a href=#force-async>"force-async"</a> flag must first be unset, and then the
+ content attribute must be removed if the IDL attribute's new value
+ is false, and must be set to the empty string if the IDL attribute's
+ new value is true. If the element's <a href=#force-async>"force-async"</a> flag
+ is <em>not</em> set, the IDL attribute must <a href=#reflect>reflect</a> the
+ <code title=attr-script-async><a href=#attr-script-async>async</a></code> content attribute.</p>
+
</div>
<dl class=domintro><dt><var title="">script</var> . <code title=dom-script-text><a href=#dom-script-text>text</a></code> [ = <var title="">value</var> ]</dt>
@@ -80953,7 +81033,8 @@ <h5 id=the-before-head-insertion-mode><span class=secno>12.2.5.6 </span>The "<df
<li>
- <p>Mark the element as being <a href=#parser-inserted>"parser-inserted"</a>.</p>
+ <p>Mark the element as being <a href=#parser-inserted>"parser-inserted"</a> and
+ unset the element's <a href=#force-async>"force-async"</a> flag.</p>
<p class=note>This ensures that, if the script is external,
any <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code>
@@ -84030,11 +84111,14 @@ <h4 id=the-end><span class=secno>12.2.6 </span>The end</h4>
<code><a href=#document>Document</a></code>.</li>
<li><p><a href=#spin-the-event-loop>Spin the event loop</a> until the <a href=#set-of-scripts-that-will-execute-as-soon-as-possible>set of
- scripts that will execute as soon as possible</a> is
- empty.</li> <!-- this step is redundant with the next one,
- really, since all those scripts also delay the load event. It's
- here in case we add an event between this step and the next or if
- we move the previous step (DOMContentLoaded) down again. -->
+ scripts that will execute as soon as possible</a> and the
+ <a href=#list-of-scripts-that-will-execute-in-order-as-soon-as-possible>list of scripts that will execute in order as soon as
+ possible</a> are empty.</li> <!-- this step is not redundant
+ with the next one, since <script> nodes delay the load event of the
+ document they are in, but they might change document between being
+ added to one document's set/list and executing those scripts, so
+ they might be delaying another document but still be in this
+ document's set/list. -->
<li><p><a href=#spin-the-event-loop>Spin the event loop</a> until there is nothing that
<dfn id=delay-the-load-event title="delay the load event">delays the load event</dfn> in
@@ -85032,13 +85116,14 @@ <h3 id=parsing-xhtml-documents><span class=secno>13.2 </span>Parsing XHTML docum
<p id=scriptTagXML>When an <a href=#xml-parser>XML parser</a> creates a
<code><a href=#script>script</a></code> element, it must be marked as being
- <a href=#parser-inserted>"parser-inserted"</a>. If the parser was originally
- created for the <a href=#xml-fragment-parsing-algorithm>XML fragment parsing algorithm</a>, then
- the element must be marked as <a href=#already-started>"already started"</a>
- also. When the element's end tag is parsed, the user agent must
- <a href=#running-a-script title="running a script">run</a> the <code><a href=#script>script</a></code>
- element. If this causes there to be a <a href=#pending-parsing-blocking-script>pending parsing-blocking
- script</a>, then the user agent must run the following steps:</p>
+ <a href=#parser-inserted>"parser-inserted"</a> and its <a href=#force-async>"force-async"</a>
+ flag must be unset. If the parser was originally created for the
+ <a href=#xml-fragment-parsing-algorithm>XML fragment parsing algorithm</a>, then the element must
+ be marked as <a href=#already-started>"already started"</a> also. When the element's
+ end tag is parsed, the user agent must <a href=#running-a-script title="running a
+ script">run</a> the <code><a href=#script>script</a></code> element. If this causes
+ there to be a <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>, then the
+ user agent must run the following steps:</p>
<ol><li><p>Block this instance of the <a href=#xml-parser>XML parser</a>, such
that the <a href=#event-loop>event loop</a> will not run <a href=#concept-task title=concept-task>tasks</a> that invoke it.</li>
Oops, something went wrong.

0 comments on commit 9869b02

Please sign in to comment.