Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[gi] (2) Define how innerHTML triggers <script defer> scripts. This i…
…s pretty ridiculous.

git-svn-id: http://svn.whatwg.org/webapps@3456 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jul 21, 2009
1 parent a549084 commit 9c7486a
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 2 deletions.
51 changes: 49 additions & 2 deletions index
Expand Up @@ -67,7 +67,7 @@
<div class=head>
<p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
<h1>HTML 5</h1>
<h2 class="no-num no-toc" id=draft-standard-&mdash;-date:-01-jan-1901>Draft Standard &mdash; 20 July 2009</h2>
<h2 class="no-num no-toc" id=draft-standard-&mdash;-date:-01-jan-1901>Draft Standard &mdash; 21 July 2009</h2>
<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>-->
Expand Down Expand Up @@ -9359,6 +9359,46 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0

<ol><li>

<p>If the node is an <code>Element</code> node, and the node's
document is an <a href=#html-documents title="HTML documents">HTML document</a>,
and the node is <a href=#in-a-document>in a <code>Document</code></a>, and the
node's document has an <a href=#active-parser>active parser</a>, and the
<a href=#insertion-point>insertion point</a> associated with that parser's
<a href=#the-input-stream>input stream</a> is not undefined (that is, it
<em>does</em> point to somewhere in the input stream), and 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, then run the following
substeps:</p>

<ol><li><p>Let <var title="">the script</var> be the first element 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>.</li>

<li><p><a href=#pause>Pause</a> until <var title="">the script</var>
has <a href=#completed-loading>completed loading</a>.</li>

<li><p><a href=#executing-a-script-block title="executing a script block">Execute</a> <var title="">the script</var>.</li>

<li><p>Remove <var title="">the script</var> from 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> (i.e. shift out the first entry in the
list).</li>

<li><p>If there are any more entries 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>
then jump back to step 1.</li>

</ol><!--
TESTS: http://www.hixie.ch/tests/adhoc/html/parsing/script-defer-write/
Note: IE8 actually drops on the floor any scripts which in step 2
of the algorithm above aren't yet completely loaded. I don't want
to spec a race condition, though. The alternative to pausing like
above, however, is to blow away the doc if the external scripts
do document.write(), which apparently might cause issues.
--></li>

<li>

<p>If the node's document is an <a href=#html-documents title="HTML documents">HTML
document</a>: Invoke the <a href=#html-fragment-parsing-algorithm>HTML fragment parsing
algorithm</a>.</p>
Expand Down Expand Up @@ -11423,6 +11463,8 @@ people expect to have work and what is necessary.
http://www.websiteoptimization.com/speed/tweak/defer/test/
internal deferred scripts execute before any external scripts execute, or before the LOAD if there are none
external deferred scripts execute before the LOAD
See also the innerHTML attribute, which does weird things for
this list of scripts.
-->

</dd>
Expand Down Expand Up @@ -11514,7 +11556,12 @@ people expect to have work and what is necessary.

</li>

</ol></dd>
</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>
Expand Down
55 changes: 55 additions & 0 deletions source
Expand Up @@ -9662,6 +9662,53 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0

<ol>

<li>

<p>If the node is an <code>Element</code> node, and the node's
document is an <span title="HTML documents">HTML document</span>,
and the node is <span>in a <code>Document</code></span>, and the
node's document has an <span>active parser</span>, and the
<span>insertion point</span> associated with that parser's
<span>input stream</span> is not undefined (that is, it
<em>does</em> point to somewhere in the input stream), and the
<span>list of scripts that will execute when the document has
finished parsing</span> is not empty, then run the following
substeps:</p>

<ol>

<li><p>Let <var title="">the script</var> be the first element in
the <span>list of scripts that will execute when the document has
finished parsing</span>.</p></li>

<li><p><span>Pause</span> until <var title="">the script</var>
has <span>completed loading</span>.</p></li>

<li><p><span title="executing a script block">Execute</span> <var
title="">the script</var>.</p></li>

<li><p>Remove <var title="">the script</var> from the <span>list
of scripts that will execute when the document has finished
parsing</span> (i.e. shift out the first entry in the
list).</p></li>

<li><p>If there are any more entries in the <span>list of scripts
that will execute when the document has finished parsing</span>
then jump back to step 1.</p></li>

</ol>

<!--
TESTS: http://www.hixie.ch/tests/adhoc/html/parsing/script-defer-write/
Note: IE8 actually drops on the floor any scripts which in step 2
of the algorithm above aren't yet completely loaded. I don't want
to spec a race condition, though. The alternative to pausing like
above, however, is to blow away the doc if the external scripts
do document.write(), which apparently might cause issues.
-->

</li>

<li>

<p>If the node's document is an <span title="HTML documents">HTML
Expand Down Expand Up @@ -12051,6 +12098,8 @@ people expect to have work and what is necessary.
http://www.websiteoptimization.com/speed/tweak/defer/test/
internal deferred scripts execute before any external scripts execute, or before the LOAD if there are none
external deferred scripts execute before the LOAD
See also the innerHTML attribute, which does weird things for
this list of scripts.
-->

</dd>
Expand Down Expand Up @@ -12158,6 +12207,12 @@ people expect to have work and what is necessary.

</ol>

<p class="note">The scripts in the <span>list of scripts that will
execute when the document has finished parsing</span> can also get
executed prematurely if the <code
title="dom-innerHTML">innerHTML</code> attribute is set on a node
in the document.</p>

</dd>

<dt>If the <code>script</code> element was added to the <dfn>list
Expand Down

0 comments on commit 9c7486a

Please sign in to comment.