Context:
|
const originalPropertyDescriptor = Object.getOwnPropertyDescriptor( |
|
patchTarget?.prototype, |
|
'adoptedStyleSheets', |
|
); |
|
if ( |
|
hostId === null || |
|
hostId === -1 || |
|
!patchTarget || |
|
!originalPropertyDescriptor |
|
) |
|
return () => { |
|
// |
|
}; |
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 () => {
//
};
Context:
rrweb/packages/rrweb/src/record/observer.ts
Lines 843 to 855 in 94d408f
In the lines
patchTargetis sometimes null. This causesgetOwnPropertyDescriptorto throwTypeError: Function.getOwnPropertyDescriptor: Cannot convert undefined or null to object.I propose null checking before: