]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(v-model): fix the lazy modifier is not reset by other modifications (#8547)
author远方os <yangpanteng@gmail.com>
Fri, 31 May 2024 13:05:41 +0000 (21:05 +0800)
committerGitHub <noreply@github.com>
Fri, 31 May 2024 13:05:41 +0000 (21:05 +0800)
close #8546
close #6564
close #6773

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

index b0ea41728bd08443a53d12139e2d0a3b70cdcac0..95685540a9625be19a33c63d715cba7fbb15f61e 100644 (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) {