Skip to content

Commit

Permalink
fix(runtime-dom): prevent unnecessary updates in v-model checkbox whe…
Browse files Browse the repository at this point in the history
…n value is unchanged
  • Loading branch information
jh-leong committed Oct 10, 2024
1 parent 35785f3 commit f9e3ca1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/runtime-dom/src/directives/vModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const vModelCheckbox: ModelDirective<HTMLInputElement> = {

function setChecked(
el: HTMLInputElement,
{ value }: DirectiveBinding,
{ value, oldValue }: DirectiveBinding,
vnode: VNode,
) {
// store the v-model value on the element so it can be accessed by the
Expand All @@ -177,7 +177,7 @@ function setChecked(
}

// Only update if the checked state has changed
if (el.checked !== checked) {
if (el.checked !== checked && value !== oldValue) {
el.checked = checked
}
}
Expand Down

0 comments on commit f9e3ca1

Please sign in to comment.