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
use an object as v-for's key will clear input's value #5804
Comments
@autumnwoodberry I updated my fiddle and use |
@lmk123 I was wrong. I did notice that you don't actually have to click the |
@autumnwoodberry Thank you to point it out. I updated my description and fiddle. |
Thanks @lmk123 , is there any case you have to do like this, why not just use You could refer the |
Although my PR may solve this problem, you'd better only use string or number type value for key attributes. |
If I recall correctly, |
There's a reason we don't support object as keys: performance. This diffing part of the code is extremely perf-sensitive, and the extra memory allocation and We should add a warning for non-primitive keys, probably in Using native Map will solve the problem with less perf hit, but that would make Vue's behavior inconsistent depending on browser support, so this will likely only be supported in a future version where IE9~11 are no longer supported. I haven't really seen a case where object keys are absolutely necessary - in most cases you can just make sure the objects have ids when you create them. This is somewhat inconvenient, but I don't think it's worth the perf tradeoff. |
Thank you for explanations. |
Version
2.3.3
Reproduction link
https://jsfiddle.net/lmk123/fkLhx1n6/
Steps to reproduce
Shuffle
button 10 timesWhat is expected?
Every person's id should stay in the input fields.
What is actually happening?
Some person's id has been cleared.
Only if the array starts with more than 3 items will reproduce this bug.
The text was updated successfully, but these errors were encountered: