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
2023-07-07 15:22:54 +02:00
committed by GitHub
parent bbbfa226fc
commit d0fbe23c63
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(