Skip to content

Commit

Permalink
🐞 fix(web-extension): beforeunload logic
Browse files Browse the repository at this point in the history
check `newEvents` before `event.preventDefault`
  • Loading branch information
huangkairan committed Oct 20, 2023
1 parent 8444cb2 commit 59bf03c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/web-extension/src/content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ async function initMainPage() {

// Before unload pages, cache the new events in the local storage.
window.addEventListener('beforeunload', (event) => {
if (!newEvents.length) return;
event.preventDefault();
if (newEvents.length === 0) return;
void Browser.storage.local.set({
[LocalDataKey.bufferedEvents]: bufferedEvents.concat(newEvents),
});
Expand Down

0 comments on commit 59bf03c

Please sign in to comment.