fix(runtime-dom): avoid setting unchanged input value (#1937)

fix #1935 (fix v-model usage with HTML5 validation)
This commit is contained in:
ᴜɴвʏтᴇ 2020-08-25 21:47:55 +08:00 committed by GitHub
parent 67b6e0f894
commit 1d55454e61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -85,7 +85,10 @@ export const vModelText: ModelDirective<
return return
} }
} }
el.value = value == null ? '' : value const newValue = value == null ? '' : value
if (el.value !== newValue) {
el.value = newValue
}
} }
} }

View File

@ -28,7 +28,10 @@ export function patchDOMProp(
// store value as _value as well since // store value as _value as well since
// non-string values will be stringified. // non-string values will be stringified.
el._value = value el._value = value
el.value = value == null ? '' : value const newValue = value == null ? '' : value
if (el.value !== newValue) {
el.value = newValue
}
return return
} }
if (value === '' && typeof el[key] === 'boolean') { if (value === '' && typeof el[key] === 'boolean') {