html5/spec Overview.html,1.5241,1.5242

Update of /sources/public/html5/spec
In directory hutz:/tmp/cvs-serv18118

Modified Files:
	Overview.html 
Log Message:
Add script.readyState and fire 'readystatechange' in some cases. Not 100% IE compatible because IE is pretty inconsistent here. Should be compatible with legacy content though, both in browsers that do script prefetch and those that don't. (whatwg r6543)

Index: Overview.html
===================================================================
RCS file: /sources/public/html5/spec/Overview.html,v
retrieving revision 1.5241
retrieving revision 1.5242
diff -u -d -r1.5241 -r1.5242
--- Overview.html	6 Sep 2011 07:23:11 -0000	1.5241
+++ Overview.html	7 Sep 2011 21:56:30 -0000	1.5242
@@ -321,7 +321,7 @@
 
    <h1>HTML5</h1>
    <h2 class="no-num no-toc" id="a-vocabulary-and-associated-apis-for-html-and-xhtml">A vocabulary and associated APIs for HTML and XHTML</h2>
-   <h2 class="no-num no-toc" id="editor-s-draft-6-september-2011">Editor's Draft 6 September 2011</h2>
+   <h2 class="no-num no-toc" id="editor-s-draft-7-september-2011">Editor's Draft 7 September 2011</h2>
    <dl><dt>Latest Published Version:</dt>
     <dd><a href="http://www.w3.org/TR/html5/">http://www.w3.org/TR/html5/</a></dd>
     <dt>Latest Editor's Draft:</dt>
@@ -467,7 +467,7 @@
   Group</a> is the W3C working group responsible for this
   specification's progress along the W3C Recommendation
   track.
-  This specification is the 6 September 2011 Editor's Draft.
+  This specification is the 7 September 2011 Editor's Draft.
   </p><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><p>Work on this specification is also done at the <a href="http://www.whatwg.org/">WHATWG</a>. The W3C HTML working group
   actively pursues convergence with the WHATWG, as required by the <a href="http://www.w3.org/2007/03/HTML-WG-charter">W3C HTML working
   group charter</a>.</p><!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><p>This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5
@@ -12509,6 +12509,8 @@
            attribute DOMString <a href="#dom-script-type" title="dom-script-type">type</a>;
            attribute DOMString <a href="#dom-script-charset" title="dom-script-charset">charset</a>;
            attribute DOMString <a href="#dom-script-text" title="dom-script-text">text</a>;
+
+  readonly attribute DOMString <a href="#dom-script-readystate" title="dom-script-readyState">readyState</a>;
 };</pre>
    </dd>
   </dl><p>The <code><a href="#the-script-element">script</a></code> element allows authors to include dynamic
@@ -12607,6 +12609,38 @@
   <a href="#parser-inserted">"parser-inserted"</a>, to let the parser know when to
   execute the script.</p>
 
+  <p>The fifth is the <dfn id="concept-script-state" title="concept-script-state">current
+  status</dfn> of the script. This is a string. When the element is
+  created, if the user agent does not intend to prefetch the script
+  (i.e. the script, if any, will only be obtained once the
+  <a href="#prepare-a-script">prepare a script</a> algorithm requires it to be fetched),
+  then the <a href="#concept-script-state" title="concept-script-state">current status</a>
+  must be set to "<code title="">loaded</code>". If the user agent
+  <em>does</em> intend to prefetch the script (if any), <a href="#scriptPrefetch">as allowed</a> in the <a href="#prepare-a-script">prepare a
+  script</a> algorithm below, the <a href="#concept-script-state" title="concept-script-state">current status</a> must be set to
+  "<code title="">uninitialized</code>" when the element is created.
+  When the user agent begins to prefetch the script, it must set the
+  <a href="#concept-script-state" title="concept-script-state">current status</a> to "<code title="">loading</code>". Once the script is fetched, the user agent
+  must <a href="#queue-a-task">queue a task</a> that, if the <a href="#prepare-a-script">prepare a
+  script</a> algorithm has still not started and the fetched script
+  is still the appropriate script, sets the <a href="#concept-script-state" title="concept-script-state">current status</a> to "<code title="">loaded</code>" and <a href="#fire-a-simple-event" title="fire a simple event">fires
+  a simple event</a> named <code title="event-readystatechange"><a href="#event-readystatechange">readystatechange</a></code> at the
+  element. If the script to be loaded changes while the script is
+  being prefetched, then the user agent must prefetch the new script
+  (if any), without changing the <a href="#concept-script-state" title="concept-script-state">current status</a>. If no script is
+  ever successfully fetched (e.g. because the element is an inline
+  script) then the transition to "<code title="">loaded</code>" is
+  skipped, and so the <code title="event-readystatechange"><a href="#event-readystatechange">readystatechange</a></code> event does
+  not fire for this transition (it still fires when the <a href="#concept-script-state" title="concept-script-state">current status</a> is set to "<code title="">complete</code>" later, however). If the script to be
+  loaded changes after a script has been successfully prefetched, the
+  user agent may prefetch the new script but must not change the <a href="#concept-script-state" title="concept-script-state">current status</a> or fire any
+  events as a result. If the user agent changes its mind and decides
+  to not bother prefetching the script after all, the user agent must
+  <a href="#queue-a-task">queue a task</a> that, if the <a href="#prepare-a-script">prepare a
+  script</a> algorithm has still not started, sets the <a href="#concept-script-state" title="concept-script-state">current status</a> to "<code title="">loaded</code>" and <a href="#fire-a-simple-event" title="fire a simple event">fires
+  a simple event</a> named <code title="event-readystatechange"><a href="#event-readystatechange">readystatechange</a></code> at the
+  element.</p>
+
   <p>The last few pieces of state are <dfn id="the-script-block-s-type"><var>the script block's
   type</var></dfn>, <dfn id="the-script-block-s-character-encoding"><var>the script block's character
   encoding</var></dfn>, and <dfn id="the-script-block-s-fallback-character-encoding"><var>the script block's fallback
@@ -12834,10 +12868,20 @@
     user agent must act as if it had received an empty HTTP 400
     response.</p>
 
-    <p>For performance reasons, user agents may start fetching the
-    script as soon as the attribute is set, instead, in the hope that
-    the element will be inserted into the document. Either way, once
-    the element is <a href="#insert-an-element-into-a-document" title="insert an element into a
+    <p>If the <a href="#concept-script-state" title="concept-script-state">current status</a>
+    of the element at this stage is still "<code title="">uninitialized</code>" (meaning that the user agent
+    intended to prefetch the script as described in the next
+    paragraph, but the <a href="#prepare-a-script">prepare a script</a> algorithm was
+    started before it had a chance to do so), then, if a
+    <a href="#fetch">fetch</a> attempt was started in this step, the user
+    agent must set the <a href="#concept-script-state" title="concept-script-state">current
+    status</a> to "<code title="">loading</code>" . </p> 
+    <p id="scriptPrefetch">For performance reasons, user agents may
+    start fetching the script as soon as the attribute is set,
+    instead, in the hope that the element will be inserted into the
+    document (user agents that do this have <a href="#concept-script-state" title="concept-script-state">requirements</a> relating to what
+    events are to be fired during the process). Either way, once the
+    element is <a href="#insert-an-element-into-a-document" title="insert an element into a
     document">inserted into the document</a>, the load must have
     started. If the UA performs such prefetching, but the element is
     never inserted in the document, or the <code title="attr-script-src"><a href="#attr-script-src">src</a></code> attribute is dynamically
@@ -13012,6 +13056,18 @@
 
   <ol><li>
 
+    <p>If the <a href="#concept-script-state" title="concept-script-state">current status</a>
+    of the element at this stage is "<code title="">loading</code>"
+    (meaning that the user agent intended to <a href="#scriptPrefetch">prefetch the script</a> as allowed by the
+    <a href="#prepare-a-script">prepare a script</a> algorithm, but the fetch was not
+    completed before that algorithm was started), then the user agent
+    must set the <a href="#concept-script-state" title="concept-script-state">current
+    status</a> to "<code title="">loaded</code>".</p>
+
+   </li>
+
+   <li>
+
     <p>If the element is flagged as <a href="#parser-inserted">"parser-inserted"</a>,
     but the element's <code><a href="#document">Document</a></code> is not the
     <code><a href="#document">Document</a></code> of the parser that created the element, then
@@ -13026,8 +13082,20 @@
     <dl class="switch"><dt>If the load resulted in an error (for example a DNS error, or
      an HTTP 404 error)</dt>
 
-     <dd><p>Executing the script block must just consist of <a href="#fire-a-simple-event" title="fire a simple event">firing a simple event</a> named
-     <code title="event-error">error</code> at the element.</dd>
+     <dd>
+
+      <p>Executing the script block must consist of running the following steps:</p>
+
+      <ol><li><p>Set the <a href="#concept-script-state" title="concept-script-state">current
+       status</a> to "<code title="">complete</code>".</li>
+
+       <li><p><a href="#fire-a-simple-event">Fire a simple event</a> named <code title="event-readystatechange"><a href="#event-readystatechange">readystatechange</a></code> at the
+       element.</li>
+
+       <li><p><a href="#fire-a-simple-event">Fire a simple event</a> named <code title="event-error">error</code> at the element.</li>
+
+      </ol></dd>
+
 
      <dt>If the load was successful</dt>
 
@@ -13146,6 +13214,9 @@
 
        </li>
 
+       <li><p>Set the <a href="#concept-script-state" title="concept-script-state">current
+       status</a> to "<code title="">interactive</code>".</li>
+
        <li>
 
         <p><a href="#create-a-script-from-a-node" title="create a script from a node">Create a
@@ -13166,6 +13237,12 @@
 
        </li>
 
+       <li><p>Set the <a href="#concept-script-state" title="concept-script-state">current
+       status</a> to "<code title="">complete</code>".</li>
+
+       <li><p><a href="#fire-a-simple-event">Fire a simple event</a> named <code title="event-readystatechange"><a href="#event-readystatechange">readystatechange</a></code> at the
+       element.</li>
+
        <li>
 
         <p>If the script is from an external file, <a href="#fire-a-simple-event">fire a simple
@@ -13210,6 +13287,51 @@
 
    </dd>
 
+
+   <dt><var title="">script</var> . <code title="dom-script-readyState"><a href="#dom-script-readystate">readyState</a></code></dt>
+
+   <dd>
+
+    <p>Returns the current state of the element. The value is one of
+    the following:</p>
+
+    <dl><dt>"<code title="">uninitialized</code>"</dt>
+
+     <dd><p>The script file, if any, has not yet been loaded, but the
+     user agent will try to prefetch it as soon as possible (e.g. as
+     soon as the <code title="attr-script-src"><a href="#attr-script-src">src</a></code> attribute is
+     set).</dd>
+
+
+     <dt>"<code title="">loading</code>"</dt>
+
+     <dd><p>A script file is being downloaded in a user agent that
+     supports prefetching scripts.</dd>
+
+
+     <dt>"<code title="">loaded</code>"</dt>
+
+     <dd><p>Either a script file is loaded and ready to be executed,
+     or the script file is not loaded but the user agent does not
+     intend to prefetch the script file anyway, and will merely fetch
+     it when it is to be executed. If the element started in the <code title="">uninitialized</code>" state and the script has not yet
+     begun to be executed, then a <code title="event-readystatechange"><a href="#event-readystatechange">readystatechange</a></code> event is
+     fired when the state changes to this value.</dd>
+
+
+     <dt>"<code title="">interactive</code>"</dt>
+
+     <dd><p>The script is running.</dd>
+
+
+     <dt>"<code title="">complete</code>"</dt>
+
+     <dd><p>The script has been executed (or it failed). A <code title="event-readystatechange"><a href="#event-readystatechange">readystatechange</a></code> event is
+     fired when the state changes to this value, just before the
+     corresponding <code title="event-load">load</code> or <code title="event-error">error</code> event.</dd>
+
+    </dl></dd>
+
   </dl><div class="impl">
 
   <p>The IDL attribute <dfn id="dom-script-text" title="dom-script-text"><code>text</code></dfn> must return a
@@ -13219,6 +13341,10 @@
   tree order. On setting, it must act the same way as the
   <code><a href="#textcontent">textContent</a></code> IDL attribute.</p>
 
+  <p>The IDL attribute <dfn id="dom-script-readystate" title="dom-script-readyState"><code>readyState</code></dfn> must
+  return the element's <a href="#concept-script-state" title="concept-script-state">current
+  status</a>.</p>
+
   </div><p class="note">When inserted using the <code title="dom-document-write"><a href="#dom-document-write">document.write()</a></code> method,
   <code><a href="#the-script-element">script</a></code> elements execute (typically synchronously), but
   when inserted using <code title="dom-innerHTML">innerHTML</code> and <code title="dom-outerHTML">outerHTML</code> attributes, they do not

Received on Wednesday, 7 September 2011 21:56:41 UTC