diff --git a/packages/runtime-vapor/src/directive.ts b/packages/runtime-vapor/src/directive.ts index ab7ca782a..f255153fd 100644 --- a/packages/runtime-vapor/src/directive.ts +++ b/packages/runtime-vapor/src/directive.ts @@ -68,8 +68,9 @@ export function withDirectives( return node } - if (!currentInstance.dirs.has(node)) currentInstance.dirs.set(node, []) - const bindings = currentInstance.dirs.get(node)! + const instance = currentInstance + if (!instance.dirs.has(node)) instance.dirs.set(node, []) + const bindings = instance.dirs.get(node)! for (const directive of directives) { let [dir, source, arg, modifiers] = directive @@ -83,7 +84,7 @@ export function withDirectives( const binding: DirectiveBinding = { dir, - instance: currentInstance, + instance, source, value: null, // set later oldValue: null, @@ -93,8 +94,9 @@ export function withDirectives( bindings.push(binding) callDirectiveHook(node, binding, 'created') + effect(() => { - if (!currentInstance!.isMountedRef.value) return + if (!instance.isMountedRef.value) return callDirectiveHook(node, binding, 'updated') }) }