fix(runtime): fix recursive dispatches of unload event (#9207)

This commit is contained in:
Yoshiya Hinosawa 2021-01-21 16:44:48 +09:00 committed by GitHub
parent 8bef29fd74
commit 18ac7d40c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 3 deletions

View file

@ -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,