From: 三咲智子 Kevin Deng Date: Tue, 12 Dec 2023 07:39:00 +0000 (+0800) Subject: fix(runtime-vapor): custom directive instance X-Git-Tag: v3.6.0-alpha.1~16^2~712 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19fb55febf602c19e3ad989b2ba2a0a79518fb52;p=thirdparty%2Fvuejs%2Fcore.git fix(runtime-vapor): custom directive instance closes #50 --- diff --git a/packages/runtime-vapor/src/directive.ts b/packages/runtime-vapor/src/directive.ts index ab7ca782ad..f255153fdc 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') }) }