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

This commit is contained in:
Francesco Novy
2026-04-01 12:00:00 +08:00
committed by GitHub
parent db334d2405
commit cd577d4d1d
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 ||