Skip to content

Commit 7a64080

Browse files
authored
Merge branch 'dev' into fix-default-prop-function-dectection
2 parents 6220c2b + d6d8e3c commit 7a64080

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/mixins/form-text.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ export default {
7272
},
7373
props,
7474
data() {
75+
const { value } = this
7576
return {
76-
localValue: toString(this.value),
77-
vModelValue: this.value
77+
localValue: toString(value),
78+
vModelValue: this.modifyValue(value)
7879
}
7980
},
8081
computed: {
@@ -115,14 +116,15 @@ export default {
115116
}
116117
},
117118
watch: {
118-
value(newVal) {
119-
const stringifyValue = toString(newVal)
120-
if (stringifyValue !== this.localValue && newVal !== this.vModelValue) {
119+
value(newValue) {
120+
const stringifyValue = toString(newValue)
121+
const modifiedValue = this.modifyValue(newValue)
122+
if (stringifyValue !== this.localValue || modifiedValue !== this.vModelValue) {
121123
// Clear any pending debounce timeout, as we are overwriting the user input
122124
this.clearDebounce()
123125
// Update the local values
124126
this.localValue = stringifyValue
125-
this.vModelValue = newVal
127+
this.vModelValue = modifiedValue
126128
}
127129
}
128130
},
@@ -133,14 +135,6 @@ export default {
133135
mounted() {
134136
// Set up destroy handler
135137
this.$on('hook:beforeDestroy', this.clearDebounce)
136-
// Preset the internal state
137-
const value = this.value
138-
const stringifyValue = toString(value)
139-
/* istanbul ignore next */
140-
if (stringifyValue !== this.localValue && value !== this.vModelValue) {
141-
this.localValue = stringifyValue
142-
this.vModelValue = value
143-
}
144138
},
145139
methods: {
146140
clearDebounce() {
@@ -155,6 +149,7 @@ export default {
155149
return value
156150
},
157151
modifyValue(value) {
152+
value = toString(value)
158153
// Emulate `.trim` modifier behaviour
159154
if (this.trim) {
160155
value = value.trim()
@@ -166,7 +161,7 @@ export default {
166161
return value
167162
},
168163
updateValue(value, force = false) {
169-
const lazy = this.lazy
164+
const { lazy } = this
170165
if (lazy && !force) {
171166
return
172167
}

0 commit comments

Comments
 (0)