Skip to content

Commit

Permalink
Add "queue an element task" algorithm
Browse files Browse the repository at this point in the history
This is a specialization of "queue a task", where the event loop and the
document are derived from the element.

This helps with #4980. For now only a couple instances were converted,
but the other 200+ will follow.
  • Loading branch information
dtapuska authored and domenic committed Dec 5, 2019
1 parent f3f1f62 commit a9e1d2a
Showing 1 changed file with 43 additions and 12 deletions.
55 changes: 43 additions & 12 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -27904,7 +27904,8 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</code
pixel density</var>.</p></li>

<li>
<p><span>Queue a task</span> to:</p>
<p><span>Queue an element task</span> on the <span>DOM manipulation task source</span>
given the <code>img</code> element and following steps:</p>

<ol>
<li><p>If <i>restart animation</i> is set, then <span>restart the
Expand Down Expand Up @@ -27954,12 +27955,20 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</code
image request</span> for the <span>current request</span> and the <span>pending request</span>,
and set <span>pending request</span> to null.</p></li>

<li><p>&#x231B; <span>Queue a task</span> to change the <span>current request</span>'s <span
data-x="img-req-url">current URL</span> to the empty string, and then, if the element has a
<code data-x="attr-img-src">src</code> attribute or it <span data-x="use srcset or
picture">uses <code>srcset</code> or <code>picture</code></span>, <span
data-x="concept-event-fire">fire an event</span> named <code data-x="event-error">error</code>
at the <code>img</code> element.</p></li>
<li>
<p>&#x231B; <span>Queue an element task</span> on the <span>DOM manipulation task
source</span> given the <code>img</code> element and the following steps:</p>

<ol>
<li><p>Change the <span>current request</span>'s <span data-x="img-req-url">current
URL</span> to the empty string.</p></li>

<li><p>If the element has a <code data-x="attr-img-src">src</code> attribute or it <span
data-x="use srcset or picture">uses <code>srcset</code> or <code>picture</code></span>, <span
data-x="concept-event-fire">fire an event</span> named <code
data-x="event-error">error</code> at the <code>img</code> element.</p></li>
</ol>
</li>

<li><p>&#x231B; Return.</p></li>
</ol>
Expand Down Expand Up @@ -91539,12 +91548,15 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {

<p>To <dfn data-export="">queue a task</dfn> on a <span>task source</span> <var>source</var>,
which performs a series of steps <var>steps</var>, optionally given an event loop <var>event
loop</var>:</p>
loop</var> and a document <var>document</var>:</p>

<ol>
<li><p>If <var>event loop</var> was not given, set <var>event loop</var> to the <span>implied
event loop</span>.</p></li>

<li><p>If <var>document</var> was not given, set <var>document</var> to the <span>implied
document</span>.</p></li>

<li><p>Let <var>task</var> be a new <span data-x="concept-task">task</span>.</p></li>

<li><p>Set <var>task</var>'s <span data-x="concept-task-steps">steps</span> to
Expand All @@ -91554,7 +91566,7 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
<var>source</var>.</p></li>

<li><p>Set <var>task</var>'s <span data-x="concept-task-document">document</span> to the
<span>implied document</span>.</p></li>
<var>document</var>.</p></li>

<li><p>Set <var>task</var>'s <span>script evaluation environment settings object set</span> to an
empty <span>set</span>.</p></li>
Expand All @@ -91565,13 +91577,32 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
<li><p><span data-x="list append">Append</span> <var>task</var> to <var>queue</var>.</p></li>
</ol>

<p>To <dfn data-export="">queue an element task</dfn> on a <span>task source</span>
<var>source</var>, with an element <var>element</var> and a series of steps
<var>steps</var>:</p>

<ol>
<li><p>Let <var>document</var> be <var>element</var>'s <span>node document</span>.</p></li>

<li><p>Let <var>event loop</var> be <var>document</var>'s <span
data-x="concept-relevant-realm">relevant realm</span>'s corresponding <span>agent</span>'s
<span>event loop</span>.</p></li>

<li><p><span>Queue a task</span> given <var>source</var>, <var>event loop</var>,
<var>document</var>, and <var>steps</var>.</p></li>
</ol>

<p>To <dfn data-export="">queue a microtask</dfn> which performs a series of steps
<var>steps</var>, optionally given an event loop <var>event loop</var>:</p>
<var>steps</var>, optionally given an event loop <var>event loop</var> and a document
<var>document</var>:</p>

<ol>
<li><p>If <var>event loop</var> was not given, set <var>event loop</var> to the <span>implied
event loop</span>.</p></li>

<li><p>If <var>document</var> was not given, set <var>document</var> to the <span>implied
document</span>.</p></li>

<li><p>Let <var>microtask</var> be a new <span data-x="concept-task">task</span>.</p></li>

<li><p>Set <var>microtask</var>'s <span data-x="concept-task-steps">steps</span> to
Expand All @@ -91580,8 +91611,8 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
<li><p>Set <var>microtask</var>'s <span data-x="concept-task-source">source</span> to the
<dfn>microtask task source</dfn>.</p></li>

<li><p>Set <var>microtask</var>'s <span data-x="concept-task-document">document</span> to the
<span>implied document</span>.</p></li>
<li><p>Set <var>microtask</var>'s <span data-x="concept-task-document">document</span> to
<var>document</var>.</p></li>

<li><p>Set <var>task</var>'s <span>script evaluation environment settings object set</span> to an
empty <span>set</span>.</p></li>
Expand Down

0 comments on commit a9e1d2a

Please sign in to comment.