@@ -73,9 +73,10 @@ export default {
73
73
} ,
74
74
props,
75
75
data ( ) {
76
+ const { value } = this
76
77
return {
77
- localValue : toString ( this . value ) ,
78
- vModelValue : this . value
78
+ localValue : toString ( value ) ,
79
+ vModelValue : this . modifyValue ( value )
79
80
}
80
81
} ,
81
82
computed : {
@@ -120,14 +121,15 @@ export default {
120
121
}
121
122
} ,
122
123
watch : {
123
- value ( newVal ) {
124
- const stringifyValue = toString ( newVal )
125
- if ( stringifyValue !== this . localValue && newVal !== this . vModelValue ) {
124
+ value ( newValue ) {
125
+ const stringifyValue = toString ( newValue )
126
+ const modifiedValue = this . modifyValue ( newValue )
127
+ if ( stringifyValue !== this . localValue || modifiedValue !== this . vModelValue ) {
126
128
// Clear any pending debounce timeout, as we are overwriting the user input
127
129
this . clearDebounce ( )
128
130
// Update the local values
129
131
this . localValue = stringifyValue
130
- this . vModelValue = newVal
132
+ this . vModelValue = modifiedValue
131
133
}
132
134
}
133
135
} ,
@@ -138,14 +140,6 @@ export default {
138
140
mounted ( ) {
139
141
// Set up destroy handler
140
142
this . $on ( 'hook:beforeDestroy' , this . clearDebounce )
141
- // Preset the internal state
142
- const value = this . value
143
- const stringifyValue = toString ( value )
144
- /* istanbul ignore next */
145
- if ( stringifyValue !== this . localValue && value !== this . vModelValue ) {
146
- this . localValue = stringifyValue
147
- this . vModelValue = value
148
- }
149
143
} ,
150
144
methods : {
151
145
clearDebounce ( ) {
@@ -160,6 +154,7 @@ export default {
160
154
return value
161
155
} ,
162
156
modifyValue ( value ) {
157
+ value = toString ( value )
163
158
// Emulate `.trim` modifier behaviour
164
159
if ( this . trim ) {
165
160
value = value . trim ( )
@@ -171,7 +166,7 @@ export default {
171
166
return value
172
167
} ,
173
168
updateValue ( value , force = false ) {
174
- const lazy = this . lazy
169
+ const { lazy } = this
175
170
if ( lazy && ! force ) {
176
171
return
177
172
}
0 commit comments