Skip to content

Commit cd9d697

Browse files
committed
fix(runtime-dom): prevent unnecessary updates in v-model checkbox when value is unchanged
1 parent 35785f3 commit cd9d697

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/runtime-dom/src/directives/vModel.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export const vModelCheckbox: ModelDirective<HTMLInputElement> = {
160160

161161
function setChecked(
162162
el: HTMLInputElement,
163-
{ value }: DirectiveBinding,
163+
{ value, oldValue }: DirectiveBinding,
164164
vnode: VNode,
165165
) {
166166
// store the v-model value on the element so it can be accessed by the
@@ -173,7 +173,10 @@ function setChecked(
173173
} else if (isSet(value)) {
174174
checked = value.has(vnode.props!.value)
175175
} else {
176-
checked = looseEqual(value, getCheckboxValue(el, true))
176+
checked =
177+
value === oldValue
178+
? el.checked
179+
: looseEqual(value, getCheckboxValue(el, true))
177180
}
178181

179182
// Only update if the checked state has changed

0 commit comments

Comments
 (0)