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

Improve some internal code #1221

Merged
merged 4 commits into from
Mar 9, 2022
Merged

Improve some internal code #1221

merged 4 commits into from
Mar 9, 2022

Conversation

RobinMalfait
Copy link
Member

This PR will cleanup and refactor some internal code.

  • remove raw document.getElementById calls
  • make Disclosure implementation between React & Vue consistent
  • use a similar convention for DOM refs to other components

When we introduced the `forwardRef` for all components, we also made
sure that internal `ref`s were used to keep track of the actual DOM
node.

This code prefers the `internalXXRef` refs in favor of the
`document.getElementById` calls. This is way more React-ish, and also
fixes a few issues:

- Potential performance improvements (no need to re-query the DOM, since
  we already have a reference to the DOM node). Note: this is a *guess*,
  I didn't measure this.
- It could be that the element is rendered in another `document`, the
  correct would involve something like
  `someDOMNode.ownerDocument.getElementById(...)` but that should not be
  necessary anymore now.
@vercel
Copy link

vercel bot commented Mar 9, 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/85WwNe8WmqgUtLCwWz84FXcyppaC
✅ Preview: https://headlessui-vue-git-internal-cleanup-tailwindlabs.vercel.app

headlessui-react – ./packages/playground-react

🔍 Inspect: https://vercel.com/tailwindlabs/headlessui-react/3xwYRb9qr1v5WbtxQff9ofNxwHuv
✅ Preview: https://headlessui-react-git-internal-cleanup-tailwindlabs.vercel.app

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.

1 participant