@@ -56,12 +56,12 @@ type acceptValueElm = HTMLInputElement | HTMLSelectElement | HTMLOptionElement;
56
56
function shouldUpdateValue ( elm : acceptValueElm , checkVal : string ) : boolean {
57
57
return ( ! elm . composing && (
58
58
elm . tagName === 'OPTION' ||
59
- isDirty ( elm , checkVal ) ||
60
- isInputChanged ( elm , checkVal )
59
+ isNotInFocusAndDirty ( elm , checkVal ) ||
60
+ isDirtyWithModifiers ( elm , checkVal )
61
61
) )
62
62
}
63
63
64
- function isDirty ( elm : acceptValueElm , checkVal : string ) : boolean {
64
+ function isNotInFocusAndDirty ( elm : acceptValueElm , checkVal : string ) : boolean {
65
65
// return true when textbox (.number and .trim) loses focus and its value is
66
66
// not equal to the updated value
67
67
let notInFocus = true
@@ -71,14 +71,20 @@ function isDirty (elm: acceptValueElm, checkVal: string): boolean {
71
71
return notInFocus && elm . value !== checkVal
72
72
}
73
73
74
- function isInputChanged ( elm : any , newVal : string ) : boolean {
74
+ function isDirtyWithModifiers ( elm : any , newVal : string ) : boolean {
75
75
const value = elm . value
76
76
const modifiers = elm . _vModifiers // injected by v-model runtime
77
- if ( isDef ( modifiers ) && modifiers . number ) {
78
- return toNumber ( value ) !== toNumber ( newVal )
79
- }
80
- if ( isDef ( modifiers ) && modifiers . trim ) {
81
- return value . trim ( ) !== newVal . trim ( )
77
+ if ( isDef ( modifiers ) ) {
78
+ if ( modifiers . lazy ) {
79
+ // inputs with lazy should only be updated when not in focus
80
+ return false
81
+ }
82
+ if ( modifiers . number ) {
83
+ return toNumber ( value ) !== toNumber ( newVal )
84
+ }
85
+ if ( modifiers . trim ) {
86
+ return value . trim ( ) !== newVal . trim ( )
87
+ }
82
88
}
83
89
return value !== newVal
84
90
}
0 commit comments