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

Arrays in $refs #400

Closed
skirtles-code opened this issue Aug 12, 2020 · 2 comments
Closed

Arrays in $refs #400

skirtles-code opened this issue Aug 12, 2020 · 2 comments

Comments

@skirtles-code
Copy link
Contributor

In Vue 2, if a ref attribute was used inside a v-for it would result in an array inside $refs.

However, this is not currently true in Vue 3 rc.5. This appears to be by design, see:

vuejs/core#1166

That issue mentions the possibility of an RFC but as far as I'm aware that hasn't happened. I'm unclear what the current plan is regarding backwards compatibility with Vue 2 for this feature.

If the plan is to abandon the use of $refs arrays within v-for then this should be mentioned in the migration guide. There are also various references to the old behaviour within the current documentation.

On a related note, it's also unclear what the expectation is with regards to using ref inside a scoped slot. Scoped slots have a similar problem to v-for in that they can create multiple nodes with the same ref. I don't think the example of using a ref function with v-for would work with a scoped slot as it relies on onBeforeUpdate running on the parent. It would be good to get something on this topic somewhere in the documentation, even if only to set expectations and discourage misuse.

@luglio7
Copy link

luglio7 commented Sep 7, 2020

Any update on this ? The v3 documentation should be updated otherwise.
https://v3.vuejs.org/api/special-attributes.html#ref

@NataliaTepluhina
Copy link
Member

@skirtles-code thanks for pointing this out! I've removed the example with v-for from docs to prevent confusion

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

3 participants