fix(runtime-vapor): only update oldValue in beforeUpdate hook

This commit is contained in:
三咲智子 Kevin Deng 2024-02-07 19:47:56 +08:00
parent 94272c6163
commit f4f467811a
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
1 changed files with 2 additions and 2 deletions

View File

@ -90,7 +90,7 @@ export function withDirectives<T extends Node>(
instance, instance,
source, source,
value: null, // set later value: null, // set later
oldValue: null, oldValue: undefined,
arg, arg,
modifiers, modifiers,
} }
@ -133,6 +133,7 @@ function callDirectiveHook(
const hook = dir[name] const hook = dir[name]
if (!hook) return if (!hook) return
if (name === 'beforeUpdate') binding.oldValue = binding.value
const newValue = binding.source ? binding.source() : undefined const newValue = binding.source ? binding.source() : undefined
binding.value = newValue binding.value = newValue
// disable tracking inside all lifecycle hooks // disable tracking inside all lifecycle hooks
@ -143,7 +144,6 @@ function callDirectiveHook(
binding, binding,
]) ])
resetTracking() resetTracking()
if (name !== 'beforeUpdate') binding.oldValue = binding.value
} }
export function resolveDirective() { export function resolveDirective() {