Re: [whatwg/dom] Add abort reason to AbortSignal (PR #1027)

@yutakahirano commented on this pull request.



> @@ -1790,6 +1799,9 @@ interface AbortSignal : EventTarget {
 <p>An {{AbortSignal}} object has an associated <dfn export for=AbortSignal>aborted flag</dfn>. It is
 unset unless specified otherwise.
 
+<p>An {{AbortSignal}} object has an associated <dfn export for=AbortSignal>abort reason</dfn>, which is a
+JavaScript value.

and initially set to `undefined`.

>    attribute EventHandler onabort;
 };</pre>
 
 <dl class=domintro>
- <dt><code>AbortSignal . <a method for="AbortSignal">abort()</a></code>
- <dd>Returns an {{AbortSignal}} instance whose <a for=AbortSignal>aborted flag</a> is set.
+ <dt><code>AbortSignal . <a method for=AbortSignal>abort</a>(reason)</code>
+ <dd>Returns an {{AbortSignal}} instance whose <a for=AbortSignal>aborted flag</a> is set, and
+ <a for=AbortSignal>abort reason</a> is set to <var>reason</var> if provided, otherwise to an
+ "{{AbortError!!exception}}" {{DOMException}}.
+
+ <dt><code><var>signal</var> . <a attribute for=AbortSignal>reason</a></code>
+ <dd>Returns the <a for=AbortSignal>abort reason</a> for an {{AbortSignal}}; by default this will
+ be an "{{AbortError!!exception}}" {{DOMException}}.

> by default this will be an "AbortError" DOMException

Isn't this a bit confusing? Until the signal is aborted the reason should return `undefined` I think, and that value can be interpreted as the "default value".

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/1027#pullrequestreview-785395950

Received on Thursday, 21 October 2021 08:54:54 UTC