-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Use deep equal in mutableValue #380
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
base: master
Are you sure you want to change the base?
Conversation
@intersrc thanks! Could you add a test to cover that case? |
The test added. Now use |
Solved. |
src/components/Select.vue
Outdated
@@ -594,7 +594,7 @@ | |||
if (this.multiple) { | |||
this.onChange ? this.onChange(val) : null | |||
} else { | |||
this.onChange && val !== old ? this.onChange(val) : null | |||
this.onChange && JSON.stringify(val) !== JSON.stringify(old) ? this.onChange(val) : null |
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.
This is not a good comparison because order of properties can be different but values can be equal, so as a result comparison will fail.
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.
Modified.
This is really an issue that needs to be fixed :/ |
Sometimes,
val
&old
are objects, like{ label, value }
,val !== old
is true, but they have samelabel
&value
, this may cause a dead loop.It's better to use a deep equal here.