fix: Handle case where event is null/undefined (#1254)

* fix: Handle case where `event` is null/undefined

* add changeset
This commit is contained in:
Francesco Novy
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 64328b8a0e
commit 5c3e1cf1e7
2 changed files with 8 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
'rrweb': patch
---
Handle case where `event` is null/undefined

View File

@@ -76,10 +76,11 @@ function getEventTarget(event: Event | NonStandardEvent): EventTarget | null {
} else if ('path' in event && event.path.length) {
return event.path[0];
}
return event.target;
} catch {
return event.target;
// fallback to `event.target` below
}
return event && event.target;
}
export function initMutationObserver(