fix(v-model): fix the lazy modifier is not reset by other modifications (#8547)

close #8546
close #6564
close #6773
This commit is contained in:
远方os 2024-05-31 21:05:41 +08:00 committed by GitHub
parent 34a97edd2c
commit a52a02f43f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 2 deletions

View File

@ -82,7 +82,11 @@ export const vModelText: ModelDirective<
mounted(el, { value }) {
el.value = value == null ? '' : value
},
beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
beforeUpdate(
el,
{ value, oldValue, modifiers: { lazy, trim, number } },
vnode
) {
el[assignKey] = getModelAssigner(vnode)
// avoid clearing unresolved text. #2302
if ((el as any).composing) return
@ -97,7 +101,8 @@ export const vModelText: ModelDirective<
}
if (document.activeElement === el && el.type !== 'range') {
if (lazy) {
// #8546
if (lazy && value === oldValue) {
return
}
if (trim && el.value.trim() === newValue) {