]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-dom): avoid setting unchanged input value (#1937)
authorᴜɴвʏтᴇ <i@shangyes.net>
Tue, 25 Aug 2020 13:47:55 +0000 (21:47 +0800)
committerGitHub <noreply@github.com>
Tue, 25 Aug 2020 13:47:55 +0000 (09:47 -0400)
fix #1935 (fix v-model usage with HTML5 validation)

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

index 0516569f1a22b4b3ec1a26f9f8fafeac1229ad2b..23ebb07b3594017951009156de1b2597fdc922ac 100644 (file)
@@ -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
+    }
   }
 }
 
index ebecc8972c67f4f1197252916bbe9d3fe3900664..1a50d612b5058b5705ce68b4159300ed22c8147e 100644 (file)
@@ -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') {