-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
No warning for multiple refs with same name #6366
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
Comments
The second one sounds rather like a) a mistake on your part or Could you provide a small reproduction of the problem as it appears to you? Sidenote: Are you aware that refs in a v-for end up in an array? |
So I would remove the |
@LinusBorg, agree 👍 |
Disagree -- the problem is that the refs might be specified programatically, in which case no warning would be issued even though they would save the user a lot of trouble. Some possibilities:
In 2) a linter would warn even though it shouldn't -- the two cases are mutually exclusive. A linter doesn't have enough information to reliably determine duplicate references -- only at run-time is there enough information. |
Incidentally I will try to come up with a simple test case for my original second example in the next week. |
I can concede that a linter will not catch dynamic $refs in many cases. For that, we would have to implement a warning mechanism. However, a simple check Will have to think about how that's feasable. |
@LinusBorg, there is one easy way, |
Closing due to inactivity. Please open a new issue with a reference to this one if you can follow up with more information. |
I also stumbled on If there can be multiple elements with the same |
Uh oh!
There was an error while loading. Please reload this page.
What problem does this feature solve?
Both I and a colleague have spent hours debugging issues caused by having two refs with the same name. Two cases where this can happen:
In this case, it is reasonable to assume the ref would work correctly because there will only be one "fubar" component instantiated assuming 'titles' has no duplicates. But the ref does not work right, either because ref ignores "v-if" or because ref doesn't work right in v-for.
What does the proposed API look like?
Simply issue a Vue warning when multiple refs with the same name are encountered.
The text was updated successfully, but these errors were encountered: