diff --git a/packages/runtime-dom/src/directives/vModel.ts b/packages/runtime-dom/src/directives/vModel.ts index b0ea41728bd..24d61b467ae 100644 --- a/packages/runtime-dom/src/directives/vModel.ts +++ b/packages/runtime-dom/src/directives/vModel.ts @@ -155,14 +155,16 @@ function setChecked( { value, oldValue }: DirectiveBinding, vnode: VNode, ) { - // store the v-model value on the element so it can be accessed by the - // change listener. + // #8638 + if (value === oldValue) + return // store the v-model value on the element so it can be accessed by the + // change listener. ;(el as any)._modelValue = value if (isArray(value)) { el.checked = looseIndexOf(value, vnode.props!.value) > -1 } else if (isSet(value)) { el.checked = value.has(vnode.props!.value) - } else if (value !== oldValue) { + } else { el.checked = looseEqual(value, getCheckboxValue(el, true)) } } @@ -216,8 +218,9 @@ export const vModelSelect: ModelDirective = { beforeUpdate(el, _binding, vnode) { el[assignKey] = getModelAssigner(vnode) }, - updated(el, { value, modifiers: { number } }) { - if (!el._assigning) { + updated(el, { value, oldValue, modifiers: { number } }) { + // #8579 + if (!el._assigning && value !== oldValue) { setSelected(el, value, number) } },