Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add abort reason to AbortSignal #1027

Merged
merged 20 commits into from
Nov 8, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ interface AbortController {

[SameObject] readonly attribute AbortSignal signal;

undefined abort();
undefined abort(optional any reason);
};
</pre>

Expand All @@ -1741,8 +1741,9 @@ interface AbortController {
<dt><code><var>controller</var> . <a attribute for=AbortController>signal</a></code>
<dd>Returns the {{AbortSignal}} object associated with this object.

<dt><code><var>controller</var> . <a method for=AbortController lt=abort()>abort</a>()</code>
<dd>Invoking this method will set this object's {{AbortSignal}}'s [=AbortSignal/aborted flag=] and
<dt><code><var>controller</var> . <a method for=AbortController lt=abort()>abort</a>(reason)</code>
<dd>Invoking this method will set this object's {{AbortSignal}}'s [=AbortSignal/aborted flag=],
store the <var ignore>reason</var> in this object's {{AbortSignal}}'s [=AbortSignal/abort reason=], and
nidhijaju marked this conversation as resolved.
Show resolved Hide resolved
signal to any observers that the associated activity is to be aborted.
</dl>

Expand All @@ -1762,9 +1763,9 @@ constructor steps are:
<p>The <dfn attribute for=AbortController><code>signal</code></dfn> getter steps are to return
<a>this</a>'s <a for=AbortController>signal</a>.

<p>The <dfn method for=AbortController><code>abort()</code></dfn> method steps are to
<a for=AbortSignal>signal abort</a> on <a>this</a>'s <a for=AbortController>signal</a>.

<p>The <dfn method for=AbortController><code>abort(reason)</code></dfn> method steps are to
nidhijaju marked this conversation as resolved.
Show resolved Hide resolved
<a for=AbortSignal>signal abort</a> on <a>this</a>'s <a for=AbortController>signal</a> with
<var>reason</var> if it is given.

<h3 id=interface-AbortSignal>Interface {{AbortSignal}}</h3>

Expand All @@ -1775,13 +1776,19 @@ interface AbortSignal : EventTarget {

readonly attribute boolean aborted;

readonly attribute any reason;
nidhijaju marked this conversation as resolved.
Show resolved Hide resolved

attribute EventHandler onabort;
};</pre>

annevk marked this conversation as resolved.
Show resolved Hide resolved
<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><var>signal</var> . <a attribute for=AbortSignal>reason</a></code>
<dd>Returns the <a for=AbortSignal>abort reason</a> for an {{AbortSignal}} if it has been
nidhijaju marked this conversation as resolved.
Show resolved Hide resolved
set; otherwise returns an "{{AbortError!!exception}}" {{DOMException}}.
nidhijaju marked this conversation as resolved.
Show resolved Hide resolved

<dt><code><var>signal</var> . <a attribute for=AbortSignal>aborted</a></code>
<dd>Returns true if this {{AbortSignal}}'s {{AbortController}} has signaled to abort; otherwise
false.
Expand All @@ -1790,6 +1797,9 @@ interface AbortSignal : EventTarget {
<p>An {{AbortSignal}} object has an associated <dfn export for=AbortSignal>aborted flag</dfn>. It is
nidhijaju marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this broke the builds of specs that use the aborted flag. No objections to the change; we just need to keep looking for better ways to do this sort of migration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's continue to discuss in #1030.

unset unless specified otherwise.

<p>An {{AbortSignal}} object has an associated <dfn export for=AbortSignal>abort reason</dfn>, which is a
JavaScript value given to {{AbortController}}'s {{AbortController/abort()}}, or undefined.
nidhijaju marked this conversation as resolved.
Show resolved Hide resolved

<p>An {{AbortSignal}} object has associated <dfn for=AbortSignal>abort algorithms</dfn>, which is a
<a for=/>set</a> of algorithms which are to be executed when its [=AbortSignal/aborted flag=] is
set. Unless specified otherwise, its value is the empty set.
Expand Down Expand Up @@ -1826,6 +1836,9 @@ service worker.
<p>The <dfn attribute for=AbortSignal>aborted</dfn> getter steps are to return true if <a>this</a>'s
[=AbortSignal/aborted flag=] is set; otherwise false.

<p>The <dfn attribute for=AbortSignal>reason</dfn> getter steps are to return <a>this</a>'s
<a for=AbortSignal>abort reason</a>.

<p>The <dfn attribute for=AbortSignal><code>onabort</code></dfn> attribute is an
<a>event handler IDL attribute</a> for the <dfn export for=AbortSignal><code>onabort</code></dfn>
<a>event handler</a>, whose <a>event handler event type</a> is
Expand All @@ -1836,13 +1849,18 @@ service worker.
them. For instance, if the operation has already completed.

<p>To <dfn export for=AbortSignal>signal abort</dfn>, given an {{AbortSignal}} object
<var>signal</var>, run these steps:
<var>signal</var> and an optional abort <var>reason</var>, run these steps:
nidhijaju marked this conversation as resolved.
Show resolved Hide resolved

<ol>
<li><p>If <var>signal</var>'s [=AbortSignal/aborted flag=] is set, then return.

<li><p>Set <var>signal</var>'s [=AbortSignal/aborted flag=].

<li><p>If <var>reason</var> is undefined or not given, then let <var>reason</var> be
nidhijaju marked this conversation as resolved.
Show resolved Hide resolved
a new "{{AbortError!!exception}}" {{DOMException}}.

<li><p>Set <var>signal</var>'s [=AbortSignal/abort reason=] to <var>reason</var>.

<li><p><a for=set>For each</a> <var>algorithm</var> in <var>signal</var>'s
[=AbortSignal/abort algorithms=]: run <var>algorithm</var>.

Expand All @@ -1859,14 +1877,16 @@ these steps:
<li><p>If <var>followingSignal</var>'s [=AbortSignal/aborted flag=] is set, then return.

<li><p>If <var>parentSignal</var>'s [=AbortSignal/aborted flag=] is set, then
<a for=AbortSignal>signal abort</a> on <var>followingSignal</var>.
<a for=AbortSignal>signal abort</a> on <var>followingSignal</var> with <var>parentSignal</var>'s
[=AbortSignal/abort reason=].

<li>
<p>Otherwise, <a for=AbortSignal lt=add>add the following abort steps</a> to
<var>parentSignal</var>:

<ol>
<li><p><a for=AbortSignal>Signal abort</a> on <var>followingSignal</var>.
<li><p><a for=AbortSignal>Signal abort</a> on <var>followingSignal</var> with
<var>parentSignal</var>'s [=AbortSignal/abort reason=].
</ol>
</ol>

Expand Down