diff options
Diffstat (limited to 'op_crates/web/01_event.js')
-rw-r--r-- | op_crates/web/01_event.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/op_crates/web/01_event.js b/op_crates/web/01_event.js index ed76a4281..35b269ea4 100644 --- a/op_crates/web/01_event.js +++ b/op_crates/web/01_event.js @@ -693,7 +693,7 @@ for (let i = 0; i < handlers.length; i++) { const listener = handlers[i]; - let capture, once, passive; + let capture, once, passive, signal; if (typeof listener.options === "boolean") { capture = listener.options; once = false; @@ -895,7 +895,19 @@ return; } } - + if (options?.signal) { + const signal = options?.signal; + if (signal.aborted) { + // If signal is not null and its aborted flag is set, then return. + return; + } else { + // If listener’s signal is not null, then add the following abort + // abort steps to it: Remove an event listener. + signal.addEventListener("abort", () => { + this.removeEventListener(type, callback, options); + }); + } + } listeners[type].push({ callback, options }); } |