Преглед изворни кода

fix(runtime-vapor): restore KeepAlive branch key even for falsy previous values

daiwei пре 2 месеци
родитељ
комит
4859f8901d
1 измењених фајлова са 5 додато и 5 уклоњено
  1. 5 5
      packages/runtime-vapor/src/fragment.ts

+ 5 - 5
packages/runtime-vapor/src/fragment.ts

@@ -195,16 +195,16 @@ export class DynamicFragment extends VaporFragment {
       const prevSlotOwner = setCurrentSlotOwner(this.slotOwner)
       // set currentKeepAliveCtx so nested DynamicFragments and components can capture it
       const prevKeepAliveCtx = setCurrentKeepAliveCtx(keepAliveCtx)
-      const prevBranchKey =
-        keepAliveCtx && this.keyed
-          ? keepAliveCtx.setCurrentBranchKey(this.current)
-          : undefined
+      const needBranchKey = keepAliveCtx && this.keyed
+      const prevBranchKey = needBranchKey
+        ? keepAliveCtx.setCurrentBranchKey(this.current)
+        : undefined
       const prevInstance = setCurrentInstance(instance)
       try {
         this.nodes = this.scope.run(render) || []
       } finally {
         setCurrentInstance(...prevInstance)
-        if (prevBranchKey) keepAliveCtx!.setCurrentBranchKey(prevBranchKey)
+        if (needBranchKey) keepAliveCtx.setCurrentBranchKey(prevBranchKey)
         setCurrentKeepAliveCtx(prevKeepAliveCtx)
         setCurrentSlotOwner(prevSlotOwner)
       }