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

instanceOf(Element) doesn't work in iframe #3

Closed
oliviertassinari opened this issue Feb 15, 2020 · 3 comments · Fixed by #13
Closed

instanceOf(Element) doesn't work in iframe #3

oliviertassinari opened this issue Feb 15, 2020 · 3 comments · Fixed by #13

Comments

@oliviertassinari
Copy link

@merceyz I have noticed a warning with this demo https://material-ui.com/components/drawers/#responsive-drawer which lead my track down to:

case 'Element': {
// Nextjs: Element isn't defined on the server
return t.instanceOfNode("typeof Element === 'undefined' ? Object : Element");
}

instanceOf(Element) doesn't work with different documents, e.g. iframe: facebook/prop-types#240 (comment).

We were able to work around the problem in the Popper component with: https://github.com/mui-org/material-ui/blob/c1c66903b8cc3941d0e110f13f49122effdc0e47/packages/material-ui/src/Popper/Popper.js#L238.

Any idea on how we could best solve this problem?

@oliviertassinari oliviertassinari changed the title typeof Element doesn't work in iframe instanceOf(Element) doesn't work in iframe Feb 15, 2020
@FezVrasta
Copy link

This is how we address the iframe problem in Popper 2 if it can be useful to you.

https://github.com/popperjs/popper-core/blob/master/src/dom-utils/instanceOf.js

@merceyz
Copy link
Owner

merceyz commented Feb 16, 2020

@oliviertassinari Thanks for the report, seems the only way to handle this is using a custom validator. I'll look into solving this when I have some more time.

@oliviertassinari
Copy link
Author

@merceyz Thanks, I suspect that a generic and loose validator could be a great tradeoff. It's what the Portal component used to have.
A more comprehensive solution might depends on #1.

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