Skip to content

Commit 58cc325

Browse files
authored
Introduce "mark as handled" for promises
This helps specifications avoid reaching into internal slots. Closes #829.
1 parent 8e17921 commit 58cc325

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

index.bs

+16-4
Original file line numberDiff line numberDiff line change
@@ -8390,7 +8390,7 @@ IDL [=promise type=] values are represented by ECMAScript [=PromiseCapability=]
83908390
|newCapability|).
83918391

83928392
Note: This algorithm will behave in a very similar way to the
8393-
{{%Promise.prototype.then%|Promise.then()}} method.
8393+
{{%Promise.prototype.then%|promise.then()}} method.
83948394
In particular, if the steps return a value of type |U| or
83958395
<code><a interface>Promise</a>&lt;|U|&gt;</code>, this algorithm returns a
83968396
<code><a interface>Promise</a>&lt;|U|&gt;</code> as well.
@@ -8465,11 +8465,23 @@ IDL [=promise type=] values are represented by ECMAScript [=PromiseCapability=]
84658465
1. [=Reject=] |promise| with |reason|.
84668466
1. [=Wait for all=] with |promises|, given |successSteps| and |failureSteps|.
84678467
1. Return |promise|.
8468+
8469+
<p class="note">This definition is useful when you wish to aggregate the results of multiple
8470+
promises, and then produce another promise from them, in the same way that
8471+
{{Promise/all()|Promise.all()}} functions for JavaScript code. If you do not need to produce
8472+
another promise, then [=waiting for all=] is likely better.
84688473
</div>
84698474

8470-
This phrase is useful when you wish to aggregate the results of multiple promises, and then produce
8471-
another promise from them, in the same way that {{Promise/all()|Promise.all()}} functions for
8472-
JavaScript code.
8475+
<div algorithm>
8476+
To <dfn export lt="mark a promise as handled|mark as handled">mark as handled</dfn> a
8477+
<code><a interface>Promise</a>&lt;<var ignore>T</var>&gt;</code> |promise|, set
8478+
|promise|.\[[Promise]].\[[PromiseIsHandled]] to true.
8479+
8480+
<p class="note">This definition is useful for promises for which you expect rejections to often
8481+
be ignored; it ensures such promises do not cause {{Window/unhandledrejection}} events. The most
8482+
common use case is for promise properties, which the web developer might or might not consult.
8483+
An example is the {{WritableStreamDefaultWriter/closed|writableStreamWriter.closed}} promise.
8484+
</div>
84738485

84748486

84758487
<h5 id="es-promise-examples">Examples</h5>

0 commit comments

Comments
 (0)