TypeError in "initAdoptedStyleSheetObserver"
Ozymandias9000 opened this issue · comments
Context:
rrweb/packages/rrweb/src/record/observer.ts
Lines 843 to 855 in 94d408f
In the lines
const originalPropertyDescriptor = Object.getOwnPropertyDescriptor(
patchTarget?.prototype,
'adoptedStyleSheets',
);
patchTarget
is sometimes null. This causes getOwnPropertyDescriptor
to throw TypeError: Function.getOwnPropertyDescriptor: Cannot convert undefined or null to object
.
I propose null checking before:
const originalPropertyDescriptor = patchTarget?.prototype ? Object.getOwnPropertyDescriptor(
patchTarget.prototype,
'adoptedStyleSheets',
) : null;
if (
hostId === null ||
hostId === -1 ||
!patchTarget ||
!originalPropertyDescriptor
)
return () => {
//
};