hixie: Dramatically simplify <script defer> and <script async> handling. (whatwg r4098)

hixie: Dramatically simplify <script defer> and <script async> handling.
(whatwg r4098)

http://dev.w3.org/cvsweb/html5/spec/Overview.html?r1=1.3256&r2=1.3257&f=h
http://html5.org/tools/web-apps-tracker?from=4097&to=4098

===================================================================
RCS file: /sources/public/html5/spec/Overview.html,v
retrieving revision 1.3256
retrieving revision 1.3257
diff -u -d -r1.3256 -r1.3257
--- Overview.html 9 Oct 2009 03:17:44 -0000 1.3256
+++ Overview.html 9 Oct 2009 04:36:24 -0000 1.3257
@@ -10681,9 +10681,9 @@
   specified even if the <code title="attr-script-async"><a href="#attr-script-async">async</a></code>
   attribute is specified, to cause legacy Web browsers that only
   support <code title="attr-script-defer"><a href="#attr-script-defer">defer</a></code> (and not <code title="attr-script-async"><a href="#attr-script-async">async</a></code>) to fall back to the <code title="attr-script-defer"><a href="#attr-script-defer">defer</a></code> behavior instead of the
-  synchronous blocking behavior that is the default.<p>If the <code title="attr-script-defer"><a href="#attr-script-defer">defer</a></code> attribute is
-  specified, the <code title="attr-script-src"><a href="#attr-script-src">src</a></code> attribute
-  must also be specified.<p>Changing the <code title="attr-script-src"><a href="#attr-script-src">src</a></code>, <code title="attr-script-type"><a href="#attr-script-type">type</a></code>, <code title="attr-script-charset"><a href="#attr-script-charset">charset</a></code>, <code title="attr-script-async"><a href="#attr-script-async">async</a></code>, and <code title="attr-script-defer"><a href="#attr-script-defer">defer</a></code> attributes dynamically has no
+  synchronous blocking behavior that is the default.<p>If one or both of the <code title="attr-script-defer"><a href="#attr-script-defer">defer</a></code> and <code title="attr-script-async"><a href="#attr-script-async">async</a></code> attributes are specified, the
+  <code title="attr-script-src"><a href="#attr-script-src">src</a></code> attribute must also be
+  specified.<p>Changing the <code title="attr-script-src"><a href="#attr-script-src">src</a></code>, <code title="attr-script-type"><a href="#attr-script-type">type</a></code>, <code title="attr-script-charset"><a href="#attr-script-charset">charset</a></code>, <code title="attr-script-async"><a href="#attr-script-async">async</a></code>, and <code title="attr-script-defer"><a href="#attr-script-defer">defer</a></code> attributes dynamically has no
   direct effect; these attribute are only used <span class="impl">at
   specific times described below (namely,</span> when the element is
   <a href="#insert-an-element-into-a-document" title="insert an element into a document">inserted into the
@@ -10842,35 +10842,20 @@
     <p>Then, the first of the following options that describes the
     situation must be followed:</p>
 
-    <dl class="switch"><dt>If the document is still being parsed, and the element has a
-     <code title="attr-script-defer"><a href="#attr-script-defer">defer</a></code> attribute, and the
-     element has a <code title="attr-script-src"><a href="#attr-script-src">src</a></code> attribute,
-     and the element does not have an <code title="attr-script-async"><a href="#attr-script-async">async</a></code> attribute</dt>
+    <dl class="switch"><dt>If the element has a <code title="attr-script-src"><a href="#attr-script-src">src</a></code>
+     attribute, and the element has a <code title="attr-script-defer"><a href="#attr-script-defer">defer</a></code> attribute, and the element
+     has been flagged as <a href="#parser-inserted">"parser-inserted"</a>, and the
+     element does not have an <code title="attr-script-async"><a href="#attr-script-async">async</a></code> attribute</dt>
 
      <dd>The element must be added to the end of the <a href="#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of
      scripts that will execute when the document has finished
-     parsing</a>.
-
-     </dd>
-
-
-     <dt>If the element has an <code title="attr-script-async"><a href="#attr-script-async">async</a></code> attribute and a <code title="attr-script-src"><a href="#attr-script-src">src</a></code> attribute</dt>
-
-     <dd>The element must be added to the end of the <a href="#list-of-scripts-that-will-execute-asynchronously">list of
-     scripts that will execute asynchronously</a>.</dd>
-
-
-     <dt>If the element has an <code title="attr-script-async"><a href="#attr-script-async">async</a></code> attribute but no <code title="attr-script-src"><a href="#attr-script-src">src</a></code> attribute, and the <a href="#list-of-scripts-that-will-execute-asynchronously">list
-     of scripts that will execute asynchronously</a> is not
-     empty</dt>
-
-     <dd>The element must be added to the end of the <a href="#list-of-scripts-that-will-execute-asynchronously">list of
-     scripts that will execute asynchronously</a>.</dd>
+     parsing</a>.</dd>
 
 
      <dt>If the element has a <code title="attr-script-src"><a href="#attr-script-src">src</a></code>
-     attribute and has been flagged as
-     <a href="#parser-inserted">"parser-inserted"</a></dt>
+     attribute, and the element has been flagged as
+     <a href="#parser-inserted">"parser-inserted"</a>, and the element does not have an
+     <code title="attr-script-async"><a href="#attr-script-async">async</a></code> attribute</dt>
 
      <dd>The element is the <dfn id="pending-external-script">pending external script</dfn>. (There
      can only be one such script at a time.)</dd>
@@ -10897,12 +10882,10 @@
   the resource has been <a href="#fetch" title="fetch">fetched</a> (defined
   below) has been run.</p>
 
-  <p><dfn id="when-a-script-completes-loading">When a script completes loading</dfn>: If the
-  <code><a href="#script">script</a></code> element was added to one of the lists mentioned
-  above and the document is still being parsed, then the parser
-  handles it. Otherwise, the UA must run the following steps as 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>:</p>
+  <p><dfn id="when-a-script-completes-loading">When a script completes loading</dfn>: The UA must run the
+  following steps as 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>:</p>
 
   <dl class="switch"><dt>If the <code><a href="#script">script</a></code> element was added to the <dfn id="list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list
    of scripts that will execute when the document has finished
@@ -10912,6 +10895,13 @@
 
     <ol><li>
 
+      <p>If the script's <code>Document</code> is still being parsed,
+      then the parser handles it. Abort these steps.</p>
+
+     </li>
+
+     <li>
+
       <p>If the <code><a href="#script">script</a></code> element is not the first element
       in the list, then do nothing yet. Stop going through these
       steps.</p>
@@ -10940,49 +10930,6 @@
 
      </li>
 
-    </ol><p class="note">The scripts in the <a href="#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will
-    execute when the document has finished parsing</a> can also get
-    executed prematurely if the <code title="dom-innerHTML"><a href="#dom-innerhtml">innerHTML</a></code> attribute is set on a node
-    in the document.</p>
-
-   </dd>
-
-   <dt>If the <code><a href="#script">script</a></code> element was added to the <dfn id="list-of-scripts-that-will-execute-asynchronously">list
-   of scripts that will execute asynchronously</dfn>:</dt>
-
-   <dd>
-
-    <ol><li>
-
-      <p>If the script is not the first element in the list, then do
-      nothing yet. Stop going through these steps.</p>
-
-     </li>
-
-     <li>
-
-      <p><a href="#executing-a-script-block" title="executing a script block">Execute the script
-      block</a> (the first element in the list).</p>
-
-     </li>
-
-     <li>
-
-      <p>Remove the <code><a href="#script">script</a></code> element from the list
-      (i.e. shift out the first entry in the list).</p>
-
-     </li>
-
-     <li>
-
-      <p>If there are any more scripts in the list, and the element
-      now at the head of the list had no <code title="attr-script-src"><a href="#attr-script-src">src</a></code> attribute when it was added
-      to the list, or had one, but its associated script has finished
-      loading, then jump back to step 2 to execute the script
-      associated with this element.</p>
-
-     </li>
-
     </ol></dd>
 
    <dt>If the <code><a href="#script">script</a></code> element was added to the <dfn id="list-of-scripts-that-will-execute-as-soon-as-possible">list
@@ -54858,13 +54805,7 @@
   <p>Before each step of the tokenizer, the user agent must first
   check the <a href="#parser-pause-flag">parser pause flag</a>. If it is true, then the
   tokenizer must abort the processing of any nested invocations of the
-  tokenizer, yielding control back to the caller. If it is false, then
-  the user agent may then check to see if either one of the scripts in
-  the <a href="#list-of-scripts-that-will-execute-as-soon-as-possible">list of scripts that will execute as soon as
-  possible</a> or the first script in the <a href="#list-of-scripts-that-will-execute-asynchronously">list of scripts
-  that will execute asynchronously</a>, has <a href="#completed-loading">completed
-  loading</a>. If one has, then it must be <a href="#executing-a-script-block" title="executing a
-  script block">executed</a> and removed from its list.</p>
+  tokenizer, yielding control back to the caller.</p>
 
   <p>The tokenizer state machine consists of the states defined in the
   following subsections.</p>
@@ -59874,25 +59815,20 @@
 
   <p>First, the user agent must set the <a href="#current-document-readiness">current document
   readiness</a> to "interactive" and the <a href="#insertion-point">insertion
-  point</a> to undefined.</p>
+  point</a> to undefined.</p> <!-- this also synchronously fires an
+  event -->
 
   <p>Then, the user agent must then make a list of all the scripts
   that are in the <a href="#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will execute when the
-  document has finished parsing</a>, the <a href="#list-of-scripts-that-will-execute-asynchronously">list of scripts that
-  will execute asynchronously</a>, and the <a href="#list-of-scripts-that-will-execute-as-soon-as-possible">list of scripts
+  document has finished parsing</a> and the <a href="#list-of-scripts-that-will-execute-as-soon-as-possible">list of scripts
   that will execute as soon as possible</a>. This is the <dfn id="list-of-scripts-pending-after-the-parser-stopped">list
   of scripts pending after the parser stopped</dfn>.</p>
 
-  <p>The rules for <a href="#when-a-script-completes-loading">when a script completes loading</a> start
-  applying (script execution is no longer managed by the parser).</p>
-
-  <p>If any of the scripts in the <a href="#list-of-scripts-that-will-execute-as-soon-as-possible">list of scripts that will
-  execute as soon as possible</a> have <a href="#completed-loading">completed
-  loading</a>, or if the <a href="#list-of-scripts-that-will-execute-asynchronously">list of scripts that will execute
-  asynchronously</a> is not empty and the first script in that list
-  has <a href="#completed-loading">completed loading</a>, then the user agent must act as
-  if those scripts just completed loading, following the rules given
-  for that in the <code><a href="#script">script</a></code> element definition.</p>
+  <p>The document is no longer being parsed, so the rules for
+  <a href="#when-a-script-completes-loading">when a script completes loading</a> for the <a href="#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of
+  scripts that will execute when the document has finished
+  parsing</a> start applying (script execution for that list is no
+  longer managed by the parser).</p>
 
   <p>If the <a href="#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing">list of scripts that will execute when the document
   has finished parsing</a> is not empty, and the first item in this
@@ -59915,7 +59851,8 @@
   run the following steps:</p>
 
   <ol><li><a href="#queue-a-task">Queue a task</a> to set the <a href="#current-document-readiness">current document
-   readiness</a> to "complete".</li>
+   readiness</a> to "complete".</li> <!-- this also fires an event
+   synchronously during the task -->
 
    <li>If the <code>Document</code> is in a <a href="#browsing-context">browsing
    context</a>, then <a href="#queue-a-task">queue a task</a> to <a href="#fire-a-simple-event">fire a

Received on Friday, 9 October 2009 04:37:14 UTC