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.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/op_crates/web/02_abort_signal.js b/op_crates/web/02_abort_signal.js
index 908e85ac9..2b51ef1ea 100644
--- a/op_crates/web/02_abort_signal.js
+++ b/op_crates/web/02_abort_signal.js
@@ -5,6 +5,8 @@
const signalAbort = Symbol("signalAbort");
const remove = Symbol("remove");
+ const illegalConstructorKey = Symbol("illegalConstructorKey");
+
class AbortSignal extends EventTarget {
#aborted = false;
#abortAlgorithms = new Set();
@@ -29,7 +31,10 @@
this.#abortAlgorithms.delete(algorithm);
}
- constructor() {
+ constructor(key) {
+ if (key != illegalConstructorKey) {
+ throw new TypeError("Illegal constructor.");
+ }
super();
this.onabort = null;
this.addEventListener("abort", (evt) => {
@@ -50,7 +55,7 @@
}
class AbortController {
- #signal = new AbortSignal();
+ #signal = new AbortSignal(illegalConstructorKey);
get signal() {
return this.#signal;