summaryrefslogtreecommitdiff
path: root/runtime/js/99_main.js
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2021-01-21 16:44:48 +0900
committerGitHub <noreply@github.com>2021-01-21 16:44:48 +0900
commit18ac7d40c87b380ce5ed617bd7c59e344730a883 (patch)
tree2588d833bed775c22756db9e18742ec736e498da /runtime/js/99_main.js
parent8bef29fd74f24e3682069a1188386d90805a9904 (diff)
fix(runtime): fix recursive dispatches of unload event (#9207)
Diffstat (limited to 'runtime/js/99_main.js')
-rw-r--r--runtime/js/99_main.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index a6abc8d27..fd846af20 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -305,6 +305,15 @@ delete Object.prototype.__proto__;
defineEventHandler(window, "load", null);
defineEventHandler(window, "unload", null);
+ const isUnloadDispatched = Symbol.for("isUnloadDispatched");
+ // Stores the flag for checking whether unload is dispatched or not.
+ // This prevents the recursive dispatches of unload events.
+ // See https://github.com/denoland/deno/issues/9201.
+ window[isUnloadDispatched] = false;
+ window.addEventListener("unload", () => {
+ window[isUnloadDispatched] = true;
+ });
+
runtimeStart(runtimeOptions);
const {
args,