Skip to content

Commit a52a02f

Browse files
authoredMay 31, 2024··
fix(v-model): fix the lazy modifier is not reset by other modifications (#8547)
close #8546 close #6564 close #6773
1 parent 34a97ed commit a52a02f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎packages/runtime-dom/src/directives/vModel.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ export const vModelText: ModelDirective<
8282
mounted(el, { value }) {
8383
el.value = value == null ? '' : value
8484
},
85-
beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
85+
beforeUpdate(
86+
el,
87+
{ value, oldValue, modifiers: { lazy, trim, number } },
88+
vnode
89+
) {
8690
el[assignKey] = getModelAssigner(vnode)
8791
// avoid clearing unresolved text. #2302
8892
if ((el as any).composing) return
@@ -97,7 +101,8 @@ export const vModelText: ModelDirective<
97101
}
98102

99103
if (document.activeElement === el && el.type !== 'range') {
100-
if (lazy) {
104+
// #8546
105+
if (lazy && value === oldValue) {
101106
return
102107
}
103108
if (trim && el.value.trim() === newValue) {

0 commit comments

Comments
 (0)
Please sign in to comment.