diff --git a/dom.bs b/dom.bs index b64858227..634db8ec7 100644 --- a/dom.bs +++ b/dom.bs @@ -278,7 +278,11 @@ function imgFetched(ev) { Event listeners can be removed by utilizing the {{EventTarget/removeEventListener()}} -method, passing the same arguments. +method passing the same arguments. + +Alternatively, event listeners can be removed by passing an {{AbortSignal}} to +{{EventTarget/addEventListener()}} and calling {{AbortController/abort()}} on the controller +owning the signal. Events are objects too and implement the {{Event}} interface (or a derived interface). In the example above @@ -962,6 +966,7 @@ dictionary EventListenerOptions { dictionary AddEventListenerOptions : EventListenerOptions { boolean passive = false; boolean once = false; + AbortSignal signal; }; @@ -981,6 +986,7 @@ when something has occurred.
If an {{AbortSignal}} is passed for options's {{AddEventListenerOptions/signal}}, + then the event listener will be removed when signal is aborted. +
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and @@ -1064,7 +1073,7 @@ steps:
If options is a boolean, then return options. -
Return options's {{EventListenerOptions/capture}}
.
+
Return |options|["{{EventListenerOptions/capture}}"].
To flatten more options, run these @@ -1075,11 +1084,20 @@ steps:
Let once and passive be false. -
If options is a dictionary, then set passive to options's
- {{AddEventListenerOptions/passive}}
and once to options's
- {{AddEventListenerOptions/once}}
.
+
Let |signal| be null. + +
If |options| is a dictionary, then: + +
Set |passive| to |options|["{{AddEventListenerOptions/passive}}"] and |once| to + |options|["{{AddEventListenerOptions/once}}"]. + +
If |options|["{{AddEventListenerOptions/signal}}"] [=map/exists=], then set |signal| to + |options|["{{AddEventListenerOptions/signal}}"]. +
Return capture, passive, and once. +
Return capture, passive, once, and signal.
The EventTarget()
constructor, when invoked,
@@ -1105,6 +1123,9 @@ participate in a tree structure.
If signal is not null and its [=AbortSignal/aborted flag=] is + set, then return. +
If listener's callback is null, then return.
If eventTarget's event listener list does not contain an @@ -1113,6 +1134,14 @@ participate in a tree structure.
callback, and capture is listener's capture, then append listener to eventTarget's event listener list. + +If listener's signal is not null, then + add the following abort steps to it: + +
The add an event listener concept exists to ensure event handlers use @@ -1129,8 +1158,8 @@ method, when invoked, must run these steps:
Add an event listener with this and an event listener whose type is type, callback is callback, capture is capture, - passive is passive, and once is - once. + passive is passive, once is + once, and signal is signal.
To remove an event listener, given an {{EventTarget}} object @@ -9959,6 +9988,7 @@ Anthony Ramine, Arkadiusz Michalski, Arnaud Le Hors, Arun Ranganathan, +Benjamin Gruenbaum, Björn Höhrmann, Boris Zbarsky, Brandon Payton,