-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
base: main
Are you sure you want to change the base?
Conversation
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-sfc
@vue/compiler-dom
@vue/compiler-ssr
@vue/runtime-core
@vue/reactivity
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
refs[ref] = value | ||
if (canSetSetupRef(ref)) { | ||
setupState[ref] = value | ||
if (oldRef !== ref) { |
There was a problem hiding this comment.
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.
Is it possible to give a warning at runtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added warning at runtime.
Ensured that recursion does not occur with the Ref or Ref function type, but only with the string.
718ef90
to
dc1a91e
Compare
dc1a91e
to
5e273d1
Compare
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.