-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
A bug when vdom trying to update children when data being changed in some case #7199
Comments
The first button should indeed warn the user of duplicate keys as the second button does (if you change the vue file the a non-minified version) |
I think not just not warning being thrown when click on first button should be fixed. The second one which throw a js error and make page unusable on production env, what is more important, should be fixed. Even thought repeated key is not correctly in common, but this js error is introduced by framework, which will not happen when write valiant script. |
The error here is expected as such code should never be deployed, that's what dev warnings/erros are there for, to help you prevent that 😄 |
I think that is good for most case. But in this case, |
I'm sorry, some changes on the job recently, so follow up late You may feel very strange Why
|
Version
2.5.9
Reproduction link
https://codepen.io/maple-leaf/pen/BmgaqG
Steps to reproduce
change data which will raise error
buttonTypeError: Cannot read property 'key' of undefined
.safe to change data here
buttonWhat is expected?
maybe same behavior like both should raise an error, but if raise error, maybe
duplicate key
error should be showed too which will help developer easier to find what data is killing page.What is actually happening?
both data have duplicate keys, but behavior is different
why error being raise when you click
change data which will raise error
button?Because the data will raise error has some special changes. It remove all keys except duplicate key 'b' compared to initial data and the order is different.
This will make
updateChildren
function invdom/patch.js
hit this code section, which will create aoldKeyToIdx
. And then when first key 'b' comes, it will set value ofb
inoldKeyToIdx
toundefined
, and then next keyb
comes, it will compare old node and new node via function sameNode. But this time, index of old node which key isb
is undefined now. So a js error is being raised.The text was updated successfully, but these errors were encountered: