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

Use ownerDocument instead of document #1158

Merged
merged 2 commits into from
Mar 10, 2022
Merged

Use ownerDocument instead of document #1158

merged 2 commits into from
Mar 10, 2022

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Feb 26, 2022

We are currently relying on window and document, but those are not always the correct instances. When you are in an iframe or opened a new window, there is a different owner. You can get this owner by using node.ownerDocument

In this PR we will use the correct ownerDocument. In addition, we will also use the correct window which can be found via el.ownerDocument.defaultView

Fixes: #966

@vercel
Copy link

vercel bot commented Feb 26, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

headlessui-vue – ./packages/playground-vue

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-vue/CVz2hJonmTTk2eJdEcjs7mHBwaNE
✅ Preview: https://headlessui-vue-git-use-owner-document-tailwindlabs.vercel.app

headlessui-react – ./packages/playground-react

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-react/DGLT8fGEBmLm2XWHUvEtgYPTY4Rz
✅ Preview: https://headlessui-react-git-use-owner-document-tailwindlabs.vercel.app

This should ensure that in iframes and new windows the correct document
is being used.
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

Successfully merging this pull request may close these issues.

<FocusTrap /> does not work in foreign documents (i.e. new windows)
1 participant