From 57a940afac0bdd14cd82937915d53110b5311673 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 13 Oct 2023 13:05:26 +0200 Subject: [PATCH] fix: Fix checking for `patchTarget` in `initAdoptedStyleSheetObserver` (#1327) --- .changeset/calm-oranges-sin.md | 5 +++++ packages/rrweb/src/record/observer.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .changeset/calm-oranges-sin.md diff --git a/.changeset/calm-oranges-sin.md b/.changeset/calm-oranges-sin.md new file mode 100644 index 0000000000..a1449698e4 --- /dev/null +++ b/.changeset/calm-oranges-sin.md @@ -0,0 +1,5 @@ +--- +'rrweb': patch +--- + +fix: Fix checking for `patchTarget` in `initAdoptedStyleSheetObserver` diff --git a/packages/rrweb/src/record/observer.ts b/packages/rrweb/src/record/observer.ts index 02a9ae8669..c6b38cbb96 100644 --- a/packages/rrweb/src/record/observer.ts +++ b/packages/rrweb/src/record/observer.ts @@ -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 ||