fix(runtime-vapor): custom directive instance

closes #50
This commit is contained in:
三咲智子 Kevin Deng 2023-12-12 15:39:00 +08:00
parent 48e8f2c196
commit 19fb55febf
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
1 changed files with 6 additions and 4 deletions

View File

@ -68,8 +68,9 @@ export function withDirectives<T extends Node>(
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<T extends Node>(
const binding: DirectiveBinding = {
dir,
instance: currentInstance,
instance,
source,
value: null, // set later
oldValue: null,
@ -93,8 +94,9 @@ export function withDirectives<T extends Node>(
bindings.push(binding)
callDirectiveHook(node, binding, 'created')
effect(() => {
if (!currentInstance!.isMountedRef.value) return
if (!instance.isMountedRef.value) return
callDirectiveHook(node, binding, 'updated')
})
}