summaryrefslogtreecommitdiff
path: root/op_crates/web/02_abort_signal.js
diff options
context:
space:
mode:
Diffstat (limited to 'op_crates/web/02_abort_signal.js')
-rw-r--r--op_crates/web/02_abort_signal.js23
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,
});
}