fix: Fix checking for patchTarget in initAdoptedStyleSheetObserver (#1327)

This commit is contained in:
Francesco Novy
2023-10-13 13:05:26 +02:00
committed by GitHub
parent 7c0dc9dfe1
commit 57a940afac
2 changed files with 11 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
'rrweb': patch
---
fix: Fix checking for `patchTarget` in `initAdoptedStyleSheetObserver`

View File

@@ -900,10 +900,12 @@ export function initAdoptedStyleSheetObserver(
host.nodeName === '#document'
? (host as Document).defaultView?.Document
: host.ownerDocument?.defaultView?.ShadowRoot;
const originalPropertyDescriptor = Object.getOwnPropertyDescriptor(
patchTarget?.prototype,
'adoptedStyleSheets',
);
const originalPropertyDescriptor = patchTarget?.prototype
? Object.getOwnPropertyDescriptor(
patchTarget?.prototype,
'adoptedStyleSheets',
)
: undefined;
if (
hostId === null ||
hostId === -1 ||