Browse Source

fix(v-model): fix input change check for type="number"

The change should only apply to the .number modifier, not type="number".
fix #6069
Evan You 9 năm trước cách đây
mục cha
commit
0a9aab510b

+ 1 - 1
src/platforms/web/compiler/directives/model.js

@@ -158,7 +158,7 @@ function genDefaultModel (
 
   addProp(el, 'value', `(${value})`)
   addHandler(el, event, code, null, true)
-  if (trim || number || type === 'number') {
+  if (trim || number) {
     addHandler(el, 'blur', '$forceUpdate()')
   }
 }

+ 1 - 1
src/platforms/web/runtime/directives/model.js

@@ -6,7 +6,7 @@
 import { looseEqual, looseIndexOf, makeMap } from 'shared/util'
 import { warn, isAndroid, isIE9, isIE, isEdge } from 'core/util/index'
 
-const isTextInputType = makeMap('text,password,search,email,tel,url')
+const isTextInputType = makeMap('text,number,password,search,email,tel,url')
 
 /* istanbul ignore if */
 if (isIE9) {

+ 1 - 1
src/platforms/web/runtime/modules/dom-props.js

@@ -69,7 +69,7 @@ function isDirty (elm: acceptValueElm, checkVal: string): boolean {
 function isInputChanged (elm: any, newVal: string): boolean {
   const value = elm.value
   const modifiers = elm._vModifiers // injected by v-model runtime
-  if ((isDef(modifiers) && modifiers.number) || elm.type === 'number') {
+  if (isDef(modifiers) && modifiers.number) {
     return toNumber(value) !== toNumber(newVal)
   }
   if (isDef(modifiers) && modifiers.trim) {