@@ -111,8 +111,11 @@ export default {
111
111
stringifyValue ( value ) {
112
112
return isUndefined ( value ) || isNull ( value ) ? '' : String ( value )
113
113
} ,
114
- formatValue ( value , evt , applyFormatter = true ) {
114
+ formatValue ( value , evt , force = false ) {
115
115
value = this . stringifyValue ( value )
116
+ if ( this . lazy && ! force ) {
117
+ return value
118
+ }
116
119
// Emulate `.trim` modifier behaviour
117
120
if ( this . trim ) {
118
121
value = value . trim ( )
@@ -122,7 +125,7 @@ export default {
122
125
const num = parseFloat ( value )
123
126
value = isNaN ( num ) ? value : num
124
127
}
125
- if ( applyFormatter && isFunction ( this . formatter ) ) {
128
+ if ( ( ! this . lazyFormatter || force ) && isFunction ( this . formatter ) ) {
126
129
value = this . formatter ( value , evt )
127
130
}
128
131
return value
@@ -133,9 +136,7 @@ export default {
133
136
if ( ! lazy ) {
134
137
this . $emit ( 'update' , value )
135
138
}
136
- return true
137
139
}
138
- return false
139
140
} ,
140
141
onInput ( evt ) {
141
142
// `evt.target.composing` is set by Vue
@@ -145,7 +146,7 @@ export default {
145
146
return
146
147
}
147
148
const value = evt . target . value
148
- const formattedValue = this . formatValue ( value , evt , ! this . lazyFormatter )
149
+ const formattedValue = this . formatValue ( value , evt )
149
150
// Exit when the `formatter` function strictly returned `false`
150
151
// or prevented the input event
151
152
/* istanbul ignore next */
@@ -154,9 +155,8 @@ export default {
154
155
return
155
156
}
156
157
this . localValue = value
157
- if ( this . updateValue ( formattedValue , this . lazy ) ) {
158
- this . $emit ( 'input' , value )
159
- }
158
+ this . updateValue ( formattedValue , this . lazy )
159
+ this . $emit ( 'input' , formattedValue )
160
160
} ,
161
161
onChange ( evt ) {
162
162
// `evt.target.composing` is set by Vue
@@ -175,11 +175,19 @@ export default {
175
175
return
176
176
}
177
177
this . localValue = formattedValue
178
- if ( this . updateValue ( formattedValue ) ) {
179
- this . $emit ( 'change' , formattedValue )
180
- }
178
+ this . updateValue ( formattedValue , this . lazy )
179
+ this . $emit ( 'change' , formattedValue )
181
180
} ,
182
181
onBlur ( evt ) {
182
+ // Lazy v-model handling
183
+ if ( this . lazy || this . lazyFormatter ) {
184
+ const value = evt . target . value
185
+ const formattedValue = this . formatValue ( value , evt , true )
186
+ if ( formattedValue !== false ) {
187
+ this . localValue = formattedValue
188
+ this . updateValue ( formattedValue )
189
+ }
190
+ }
183
191
// Emit native blur event
184
192
this . $emit ( 'blur' , evt )
185
193
} ,
0 commit comments