Skip to content

Commit

Permalink
fix(runtime-dom): avoid setting unchanged input value (#1937)
Browse files Browse the repository at this point in the history
fix #1935 (fix v-model usage with HTML5 validation)
  • Loading branch information
unbyte authored Aug 25, 2020
1 parent 67b6e0f commit 1d55454
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/runtime-dom/src/directives/vModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ export const vModelText: ModelDirective<
return
}
}
el.value = value == null ? '' : value
const newValue = value == null ? '' : value
if (el.value !== newValue) {
el.value = newValue
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/runtime-dom/src/modules/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export function patchDOMProp(
// store value as _value as well since
// non-string values will be stringified.
el._value = value
el.value = value == null ? '' : value
const newValue = value == null ? '' : value
if (el.value !== newValue) {
el.value = newValue
}
return
}
if (value === '' && typeof el[key] === 'boolean') {
Expand Down

0 comments on commit 1d55454

Please sign in to comment.