-
-
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(v-model): vModelSelect work with custom getter and setter edge case #12428
base: main
Are you sure you want to change the base?
Conversation
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-ssr
@vue/compiler-sfc
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
LGTM. For sure this behavior is consistent with vue2 |
@@ -233,7 +239,7 @@ export const vModelSelect: ModelDirective<HTMLSelectElement, 'number'> = { | |||
el[assignKey] = getModelAssigner(vnode) | |||
}, | |||
updated(el, { value }) { | |||
if (!el._assigning) { | |||
if (!el[assigningKey] || toRaw(value) !== el[assignValueKey]) { |
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.
Using an equality check might be problematic if the collection is modified, rather than replaced.
For example:
I'm not sure how important handling cases like these is. The change doesn't make them any worse.
@@ -202,24 +209,23 @@ export const vModelRadio: ModelDirective<HTMLInputElement> = { | |||
export const vModelSelect: ModelDirective<HTMLSelectElement, 'number'> = { | |||
// <select multiple> value need to be deep traversed | |||
deep: true, | |||
created(el, { value, modifiers: { number } }, vnode) { | |||
created(el, { value, oldValue, modifiers: { number } }, vnode) { |
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 oldValue
is unused.
fix #12425