Skip to content

Commit c36d87e

Browse files
domeniclozy219
authored andcommitted
Fix example that resolves/rejects promises from in parallel
Closes whatwg#10535.
1 parent 5bab531 commit c36d87e

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Diff for: source

+16-6
Original file line numberDiff line numberDiff line change
@@ -1634,21 +1634,26 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
16341634
<p>The following solution suffers from race conditions:</p>
16351635

16361636
<ol>
1637-
<li><p>Let <var>p</var> be a new promise.</p></li>
1637+
<li><p>Let <var>p</var> be a new promise created in <span>this</span>'s <span
1638+
data-x="concept-relevant-realm">relevant realm</span>.</p></li>
16381639

16391640
<li>
16401641
<p>Run the following steps <span>in parallel</span>:</p>
16411642

16421643
<ol>
16431644
<li><p>If <var>nameList</var> <span data-x="list contains">contains</span> <var>name</var>,
1644-
reject <var>p</var> with a <code>TypeError</code> and abort these steps.</p></li>
1645+
then <span>queue a global task</span> on the <span>DOM manipulation task source</span> given
1646+
<span>this</span>'s <span>relevant global object</span> to reject <var>p</var> with a
1647+
<code>TypeError</code>, and abort these steps.</p></li>
16451648

16461649
<li><p>Do some potentially lengthy work.</p></li>
16471650

16481651
<li><p><span data-x="list append">Append</span> <var>name</var> to
16491652
<var>nameList</var>.</p></li>
16501653

1651-
<li><p>Resolve <var>p</var> with undefined.</p></li>
1654+
<li><p><span>Queue a global task</span> on the <span>DOM manipulation task source</span>
1655+
given <span>this</span>'s <span>relevant global object</span> to resolve <var>p</var> with
1656+
undefined.</p></li>
16521657
</ol>
16531658
</li>
16541659

@@ -1663,21 +1668,26 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
16631668
<span>starting a new parallel queue</span>, then:</p>
16641669

16651670
<ol>
1666-
<li><p>Let <var>p</var> be a new promise.</p></li>
1671+
<li><p>Let <var>p</var> be a new promise created in <span>this</span>'s <span
1672+
data-x="concept-relevant-realm">relevant realm</span>.</p></li>
16671673

16681674
<li>
16691675
<p><mark><span>Enqueue the following steps</span> to <var>nameListQueue</var>:</mark></p>
16701676

16711677
<ol>
16721678
<li><p>If <var>nameList</var> <span data-x="list contains">contains</span> <var>name</var>,
1673-
reject <var>p</var> with a <code>TypeError</code> and abort these steps.</p></li>
1679+
then <span>queue a global task</span> on the <span>DOM manipulation task source</span> given
1680+
<span>this</span>'s <span>relevant global object</span> to reject <var>p</var> with a
1681+
<code>TypeError</code>, and abort these steps.</p></li>
16741682

16751683
<li><p>Do some potentially lengthy work.</p></li>
16761684

16771685
<li><p><span data-x="list append">Append</span> <var>name</var> to
16781686
<var>nameList</var>.</p></li>
16791687

1680-
<li><p>Resolve <var>p</var> with undefined.</p></li>
1688+
<li><p><span>Queue a global task</span> on the <span>DOM manipulation task source</span>
1689+
given <span>this</span>'s <span>relevant global object</span> resolve <var>p</var> with
1690+
undefined.</p></li>
16811691
</ol>
16821692
</li>
16831693

0 commit comments

Comments
 (0)