fix(v-model): ensure initial value is set after other attributes
fix #2325
This commit is contained in:
parent
d1a6ce6565
commit
54ed7592e4
@ -48,8 +48,7 @@ type ModelDirective<T> = ObjectDirective<T & { _assign: AssignerFn }>
|
|||||||
export const vModelText: ModelDirective<
|
export const vModelText: ModelDirective<
|
||||||
HTMLInputElement | HTMLTextAreaElement
|
HTMLInputElement | HTMLTextAreaElement
|
||||||
> = {
|
> = {
|
||||||
created(el, { value, modifiers: { lazy, trim, number } }, vnode) {
|
created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
||||||
el.value = value == null ? '' : value
|
|
||||||
el._assign = getModelAssigner(vnode)
|
el._assign = getModelAssigner(vnode)
|
||||||
const castToNumber = number || el.type === 'number'
|
const castToNumber = number || el.type === 'number'
|
||||||
addEventListener(el, lazy ? 'change' : 'input', e => {
|
addEventListener(el, lazy ? 'change' : 'input', e => {
|
||||||
@ -77,6 +76,10 @@ export const vModelText: ModelDirective<
|
|||||||
addEventListener(el, 'change', onCompositionEnd)
|
addEventListener(el, 'change', onCompositionEnd)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// set value on mounted so it's after min/max for type="range"
|
||||||
|
mounted(el, { value }) {
|
||||||
|
el.value = value == null ? '' : value
|
||||||
|
},
|
||||||
beforeUpdate(el, { value, modifiers: { trim, number } }, vnode) {
|
beforeUpdate(el, { value, modifiers: { trim, number } }, vnode) {
|
||||||
el._assign = getModelAssigner(vnode)
|
el._assign = getModelAssigner(vnode)
|
||||||
// avoid clearing unresolved text. #2302
|
// avoid clearing unresolved text. #2302
|
||||||
|
Loading…
Reference in New Issue
Block a user