Skip to content

Commit

Permalink
[giow] (2) Make DOMContentLoaded wait until after scripts have run.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@3457 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jul 21, 2009
1 parent 9c7486a commit 2650093
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 29 deletions.
42 changes: 27 additions & 15 deletions index
Expand Up @@ -64887,12 +64887,20 @@ document.body.appendChild(text);
the document, the user agent must follow the steps in this
section.</p>

<p>First, the <a href=#current-document-readiness>current document readiness</a> must be set to
"interactive".</p>
<!-- this happens as part of one of the tasks that runs the parser -->

<p>Then, 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>First, the user agent must set the <a href=#current-document-readiness>current document
readiness</a> to "interactive".</p>

<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
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
Expand All @@ -64902,19 +64910,23 @@ document.body.appendChild(text);
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>Then, 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 list has already <a href=#completed-loading>completed loading</a>, then
the user agent must act as if that script just finished loading.</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
list has already <a href=#completed-loading>completed loading</a>, then the user agent
must act as if that script just finished loading.</p>

<p>By this point, there will be no scripts that have loaded but have
not yet been executed.</p>
<p class=note>By this point, there will be no scripts that have
loaded but have not yet been executed.</p>

<p>The user agent must then <a href=#fire-a-simple-event>fire a simple event</a> called
<code title=event-DOMContentLoaded>DOMContentLoaded</code> at the
<code>Document</code>.</p>
<hr><!-- async --><p>Once all the scripts on the <a href=#list-of-scripts-pending-after-the-parser-stopped>list of scripts pending after
the parser stopped</a> have <a href=#completed-loading>completed loading</a> and
been <a href=#executing-a-script-block title="executing a script block">executed</a>, the
user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple
event</a> called <code title=event-DOMContentLoaded>DOMContentLoaded</code> at the
<code>Document</code>. (If the list is empty, this happens
immediately.)</p>

<p>Once everything that <dfn id=delay-the-load-event title="delay the load event">delays the
<hr><!-- async --><p>Once everything that <dfn id=delay-the-load-event title="delay the load event">delays the
load event</dfn> of the document has completed, the user agent must
run the following steps:</p>

Expand Down
49 changes: 35 additions & 14 deletions source
Expand Up @@ -79242,12 +79242,20 @@ document.body.appendChild(text);
the document, the user agent must follow the steps in this
section.</p>

<p>First, the <span>current document readiness</span> must be set to
"interactive".</p>
<!-- this happens as part of one of the tasks that runs the parser -->

<p>Then, the rules for <span>when a script completes loading</span>
start applying (script execution is no longer managed by the
parser).</p>
<p>First, the user agent must set the <span>current document
readiness</span> to "interactive".</p>

<p>Then, the user agent must then make a list of all the scripts
that are in the <span>list of scripts that will execute when the
document has finished parsing</span>, the <span>list of scripts that
will execute asynchronously</span>, and the <span>list of scripts
that will execute as soon as possible</span>. This is the <dfn>list
of scripts pending after the parser stopped</dfn>.</p>

<p>The rules for <span>when a script completes loading</span> start
applying (script execution is no longer managed by the parser).</p>

<p>If any of the scripts in the <span>list of scripts that will
execute as soon as possible</span> have <span>completed
Expand All @@ -79257,17 +79265,30 @@ document.body.appendChild(text);
if those scripts just completed loading, following the rules given
for that in the <code>script</code> element definition.</p>

<p>Then, if the <span>list of scripts that will execute when the
document has finished parsing</span> is not empty, and the first
item in this list has already <span>completed loading</span>, then
the user agent must act as if that script just finished loading.</p>
<p>If the <span>list of scripts that will execute when the document
has finished parsing</span> is not empty, and the first item in this
list has already <span>completed loading</span>, then the user agent
must act as if that script just finished loading.</p>

<p>By this point, there will be no scripts that have loaded but have
not yet been executed.</p>
<p class="note">By this point, there will be no scripts that have
loaded but have not yet been executed.</p>

<p>The user agent must then <span>fire a simple event</span> called
<code title="event-DOMContentLoaded">DOMContentLoaded</code> at the
<code>Document</code>.</p>
<hr>

<!-- async -->

<p>Once all the scripts on the <span>list of scripts pending after
the parser stopped</span> have <span>completed loading</span> and
been <span title="executing a script block">executed</span>, the
user agent must <span>queue a task</span> to <span>fire a simple
event</span> called <code
title="event-DOMContentLoaded">DOMContentLoaded</code> at the
<code>Document</code>. (If the list is empty, this happens
immediately.)</p>

<hr>

<!-- async -->

<p>Once everything that <dfn title="delay the load event">delays the
load event</dfn> of the document has completed, the user agent must
Expand Down

0 comments on commit 2650093

Please sign in to comment.