From: ᴜɴвʏтᴇ Date: Tue, 25 Aug 2020 13:47:55 +0000 (+0800) Subject: fix(runtime-dom): avoid setting unchanged input value (#1937) X-Git-Tag: v3.0.0-rc.8~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d55454e61bf18cc2d6fe948c4528a680f67efe5;p=thirdparty%2Fvuejs%2Fcore.git fix(runtime-dom): avoid setting unchanged input value (#1937) fix #1935 (fix v-model usage with HTML5 validation) --- diff --git a/packages/runtime-dom/src/directives/vModel.ts b/packages/runtime-dom/src/directives/vModel.ts index 0516569f1a..23ebb07b35 100644 --- a/packages/runtime-dom/src/directives/vModel.ts +++ b/packages/runtime-dom/src/directives/vModel.ts @@ -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 + } } } diff --git a/packages/runtime-dom/src/modules/props.ts b/packages/runtime-dom/src/modules/props.ts index ebecc8972c..1a50d612b5 100644 --- a/packages/runtime-dom/src/modules/props.ts +++ b/packages/runtime-dom/src/modules/props.ts @@ -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') {