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

fix(unrefElement): don't return the Vue instance when $el is null/undefined #1657

Merged
merged 3 commits into from Jun 16, 2022

Conversation

DrJume
Copy link
Contributor

@DrJume DrJume commented Jun 2, 2022

When using unrefElement on a template ref of a Vue component which exposes a custom $el (HeadlessUI]) that points to a not rendered inner ref (v-if="false"), unrefElement returns the Vue instance object with { $el: null }. It should return null as it should unref the Vue instance ref.

The cause of this bug is how plain is checked to be a VueInstance. Rather than using the value of $el, it should check if it has a property named $el.

Description

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Update 1: added tests

DrJume and others added 3 commits June 2, 2022 21:09
…/`undefined`

When using unrefElement on a template ref of a Vue component which is not available (`v-if="false"`) it returns the Vue instance object with `{ $el: null }`. It should return `null` instead of the Vue instance object.

The cause of this bug is how `plain` is checked to be a VueInstance. Rather than using the value of `$el`, it should check if it has a property named `$el`.
@DrJume
Copy link
Contributor Author

DrJume commented Jun 2, 2022

added tests

@antfu antfu merged commit 050da20 into vueuse:main Jun 16, 2022
antfu added a commit that referenced this pull request Jun 18, 2022
antfu added a commit that referenced this pull request Jun 18, 2022
@DrJume DrJume deleted the patch-1 branch June 18, 2022 13:02
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.

None yet

2 participants