Skip to content

TypeError in "initAdoptedStyleSheetObserver" #117

@Ozymandias9000

Description

@Ozymandias9000

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 () => {
      //
    };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions