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(compiler-core): Refs inside v-for are not applied through v-bind (fix #10696) #10706

Merged

Conversation

quiteeasy
Copy link
Contributor

@quiteeasy quiteeasy commented Apr 15, 2024

The ref is resolved at runtime from the object. However, the identifier that the ref is inside a v-for is set at compile time. Due to this, the ref is often set to a random element in the list, typically the last one.

We could set the identifier that a ref is inside a v-for without having the ref props explicitly set, but that would require adding an extra prop to every element inside the v-for that has v-bind="object" set. I'm not sure if this approach is worth the added complexity, especially since the extra prop would not be used most of the time.

I'm opening a PR for the team to consider this potential solution. Let me know if you have any other thoughts or suggestions.

fix #10696

Screen.Recording.2024-04-16.at.12.00.27.AM.mov

Copy link

@marcosdissotti marcosdissotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡Obs. At condition, context.scopes.vFor > 0 maybe interesting to add in a auxiliary variable, for exemple, const hasVFor = context.scopes.vFor > 0; or hasVForDirective.

I liked your suggestion ✌️

@quiteeasy
Copy link
Contributor Author

@marcosdissotti

💡Obs. At condition, context.scopes.vFor > 0 maybe interesting to add in a auxiliary variable, for exemple, const hasVFor = context.scopes.vFor > 0; or hasVForDirective.

I liked your suggestion ✌️

Thank you for the review and the suggestion! I have added the hasVFor variable. I'm looking forward to your feedback.

Copy link

github-actions bot commented Apr 22, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 90.7 kB 34.5 kB 31.1 kB
vue.global.prod.js 148 kB (-37 B) 53.8 kB (+3 B) 48 kB (-13 B)

Usages

Name Size Gzip Brotli
createApp 50.8 kB 19.8 kB 18.1 kB
createSSRApp 54.1 kB 21.2 kB 19.3 kB
defineCustomElement 53.1 kB 20.6 kB 18.8 kB
overall 64.5 kB 24.9 kB 22.6 kB

@yyx990803 yyx990803 merged commit da7adef into vuejs:main Apr 22, 2024
11 checks passed
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.

Refs inside v-for doesn't apply through v-bind
3 participants