Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function inShadow throws error when shadowRoot is undefined #462

Open
mazengh opened this issue Sep 6, 2023 · 1 comment
Open

function inShadow throws error when shadowRoot is undefined #462

mazengh opened this issue Sep 6, 2023 · 1 comment

Comments

@mazengh
Copy link

mazengh commented Sep 6, 2023

I am using latest antd library version 5.8.6 which is dependent on rc-util. There is an edge case where shadowRoot is undefined. When inShadow function is called, the whole page breaks throwing the error below.

VM107071:1 Uncaught TypeError: Right-hand side of 'instanceof' is not an object

It used to work when function returned return getRoot(ele) !== ele?.ownerDocument;

Version: rc-util: 5.37.0

@mazengh
Copy link
Author

mazengh commented Sep 6, 2023

is it possible to create a PR to change the logic as below?

export function inShadow(ele: Node) {
  const root = getRoot(ele);
  return ShadowRoot ? root instanceof ShadowRoot : root !== ele?.ownerDocument;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant