Skip to content

Commit

Permalink
fix: Fix checking for patchTarget in initAdoptedStyleSheetObserver
Browse files Browse the repository at this point in the history
Calling `Object.getOwnPropertyDescriptor(undefined, 'xx')` actually errors out, so let's guard there.
  • Loading branch information
mydea committed Oct 13, 2023
1 parent 58c9104 commit b4af692
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/rrweb/src/record/observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down

0 comments on commit b4af692

Please sign in to comment.