Skip to content

Commit

Permalink
fix(web-extension): beforeunload logic (#1330)
Browse files Browse the repository at this point in the history
  • Loading branch information
huangkairan authored Nov 3, 2023
1 parent 05478c3 commit 9e65dda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/witty-kids-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rrweb/web-extension': patch
---

🐞 fix(web-extension): beforeunload logic
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 9e65dda

Please sign in to comment.