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(runtime-core): multiple ref elements with the same name #12268

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tsiotska
Copy link

@tsiotska tsiotska commented Oct 25, 2024

close: #12246

The solution is more like a stub.
Idea is same to keep setting the last ref if multiple same are in template without breaking the code.
Effectively stopped the occurrence of recursion using conditional check

Added appropriate tests.
The best idea would be to set and operate via unique keys and throw a warning in dev mode that ref names should be unique for each element.
Also, would like to cautiously refactor the "if-mess" if the solution is approved.

Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB (+14 B) 38 kB (-1 B) 34.2 kB (+16 B)
vue.global.prod.js 159 kB (+14 B) 57.9 kB 51.4 kB (-37 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.9 kB (+14 B) 18.3 kB (-1 B) 16.7 kB (+4 B)
createApp 55 kB (+14 B) 21.3 kB (-1 B) 19.4 kB (+7 B)
createSSRApp 59 kB (+14 B) 23 kB (-1 B) 20.9 kB (-9 B)
defineCustomElement 59.8 kB (+14 B) 22.8 kB (-3 B) 20.8 kB (-65 B)
overall 68.7 kB (+14 B) 26.3 kB 23.9 kB (-51 B)

Copy link

pkg-pr-new bot commented Oct 27, 2024

Open in Stackblitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@12268

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@12268

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@12268

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@12268

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@12268

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@12268

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@12268

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@12268

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@12268

vue

pnpm add https://pkg.pr.new/vue@12268

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@12268

commit: 161939a

refs[ref] = value
if (canSetSetupRef(ref)) {
setupState[ref] = value
if (oldRef !== ref) {
Copy link
Member

@edison1105 edison1105 Oct 27, 2024

Choose a reason for hiding this comment

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

I think this solution is OK.
Maybe we can issue a runtime warning when oldRef === ref.

@edison1105 edison1105 added 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. wait changes labels Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. wait changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dupliucate ref in template with v-if checking for the ref leads to a recursion error
2 participants