Skip to content

Commit ab185e8

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

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

+2-1
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,6 +173,7 @@ function setChecked(
173173
} else if (isSet(value)) {
174174
checked = value.has(vnode.props!.value)
175175
} else {
176+
if (value === oldValue) return
176177
checked = looseEqual(value, getCheckboxValue(el, true))
177178
}
178179

0 commit comments

Comments
 (0)