fix(web-extension): beforeunload logic (#1330)

This commit is contained in:
huangkairan
2023-11-04 06:10:00 +08:00
committed by GitHub
parent 05478c36dd
commit 9e65dda258
2 changed files with 6 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'@rrweb/web-extension': patch
---
🐞 fix(web-extension): beforeunload logic

View File

@@ -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),
});