From f4f467811ae4d0c910605f78adb4dcc6911c20f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Wed, 7 Feb 2024 19:47:56 +0800 Subject: [PATCH] fix(runtime-vapor): only update oldValue in beforeUpdate hook --- packages/runtime-vapor/src/directive.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/runtime-vapor/src/directive.ts b/packages/runtime-vapor/src/directive.ts index 54c4500c6..43539f647 100644 --- a/packages/runtime-vapor/src/directive.ts +++ b/packages/runtime-vapor/src/directive.ts @@ -90,7 +90,7 @@ export function withDirectives( instance, source, value: null, // set later - oldValue: null, + oldValue: undefined, arg, modifiers, } @@ -133,6 +133,7 @@ function callDirectiveHook( const hook = dir[name] if (!hook) return + if (name === 'beforeUpdate') binding.oldValue = binding.value const newValue = binding.source ? binding.source() : undefined binding.value = newValue // disable tracking inside all lifecycle hooks @@ -143,7 +144,6 @@ function callDirectiveHook( binding, ]) resetTracking() - if (name !== 'beforeUpdate') binding.oldValue = binding.value } export function resolveDirective() {