Skip to content

Commit

Permalink
fix(v-model): fix the lazy modifier is not reset by other modificatio…
Browse files Browse the repository at this point in the history
…ns (#8547)

close #8546
close #6564
close #6773
  • Loading branch information
Alfred-Skyblue authored May 31, 2024
1 parent 34a97ed commit a52a02f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/runtime-dom/src/directives/vModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit a52a02f

Please sign in to comment.