Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request authts#330 from authts/fix-redirect-unload
Browse files Browse the repository at this point in the history
fix(RedirectNavigator): wait for 'unload' instead of 'beforeunload'
  • Loading branch information
pamapa authored Jan 16, 2022
2 parents 74ee0bc + 608668b commit 02733aa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/navigators/RedirectNavigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class RedirectNavigator implements INavigator {
this._logger.create("navigate");
const promise = new Promise((resolve, reject) => {
abort = reject;
window.addEventListener("beforeunload", () => resolve(null));
window.addEventListener("unload", () => resolve(null));
});
redirect(params.url);
return await (promise as Promise<never>);
Expand Down
2 changes: 1 addition & 1 deletion test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Log } from "../src";
beforeAll(() => {
globalThis.fetch = jest.fn();

const unload = () => window.dispatchEvent(new Event("beforeunload"));
const unload = () => window.dispatchEvent(new Event("unload"));

const location = Object.defineProperties({}, {
...Object.getOwnPropertyDescriptors(window.location),
Expand Down

0 comments on commit 02733aa

Please sign in to comment.