]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-vapor): custom directive instance
author三咲智子 Kevin Deng <sxzz@sxzz.moe>
Tue, 12 Dec 2023 07:39:00 +0000 (15:39 +0800)
committer三咲智子 Kevin Deng <sxzz@sxzz.moe>
Tue, 12 Dec 2023 07:39:00 +0000 (15:39 +0800)
closes #50

packages/runtime-vapor/src/directive.ts

index ab7ca782ad80cf0fc92a79459c2444254493c738..f255153fdc406ce155de26c29ba96d8e18fdcb64 100644 (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')
     })
   }