From 3acd7350684410d6b63b3b30b55d23bcecb3b16e Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Thu, 20 Nov 2025 14:12:04 +0900 Subject: [PATCH] Add abortSignal.addAbortCallback --- dom.bs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dom.bs b/dom.bs index 70e029a6..94217174 100644 --- a/dom.bs +++ b/dom.bs @@ -1926,6 +1926,7 @@ interface AbortSignal : EventTarget { readonly attribute boolean aborted; readonly attribute any reason; undefined throwIfAborted(); + undefined addAbortCallback(VoidFunction callback); attribute EventHandler onabort; }; @@ -2037,6 +2038,26 @@ is [=AbortSignal/aborted=]; otherwise false.

The throwIfAborted() method steps are to throw this's abort reason, if this is [=AbortSignal/aborted=]. +

+

The addAbortCallback(callback) method steps are: + +

    +
  1. If this is [=AbortSignal/aborted=], then: +

      +
    1. invoke callback with « », and "report". + +

    2. Return. +

    + + +
  2. +

    [=AbortSignal/Add|Add the following abort steps=] to [=this=]:

    +
      +
    1. invoke callback with « », and "report". +

    +
+
+

This method is primarily useful for when functions accepting {{AbortSignal}}s want to throw (or return a rejected promise) at specific checkpoints, instead of passing along the {{AbortSignal}}