diff options
author | Benjamin Gruenbaum <benjamingr@gmail.com> | 2020-11-03 01:42:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-03 10:42:40 +1100 |
commit | 1c1889851d91807a1d480c79436dce4a32f61e9d (patch) | |
tree | 791a7b29449a8b8bf11c3d35726b0644e4dde0bd /op_crates/web/02_abort_signal.js | |
parent | c3dd19c5d37a9c0801857669b59bd708a5bb0a71 (diff) |
fix(op_crate/web): make onabort event handler web compatible (#8225)
Diffstat (limited to 'op_crates/web/02_abort_signal.js')
-rw-r--r-- | op_crates/web/02_abort_signal.js | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/op_crates/web/02_abort_signal.js b/op_crates/web/02_abort_signal.js index 2b51ef1ea..a963b1807 100644 --- a/op_crates/web/02_abort_signal.js +++ b/op_crates/web/02_abort_signal.js @@ -36,12 +36,23 @@ throw new TypeError("Illegal constructor."); } super(); - this.onabort = null; - this.addEventListener("abort", (evt) => { - const { onabort } = this; - if (typeof onabort === "function") { - onabort.call(this, evt); - } + // HTML specification section 8.1.5.1 + let eventHandler = null; + Object.defineProperty(this, "onabort", { + get() { + return eventHandler; + }, + set(value) { + if (eventHandler) { + this.removeEventListener("abort", eventHandler); + } + eventHandler = value; + if (typeof eventHandler === "function") { + this.addEventListener("abort", value); + } + }, + configurable: true, + enumerable: true, }); } |