Skip to content

Commit 4859f89

Browse files
committed
fix(runtime-vapor): restore KeepAlive branch key even for falsy previous values
1 parent e7692bc commit 4859f89

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/runtime-vapor/src/fragment.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,16 @@ export class DynamicFragment extends VaporFragment {
195195
const prevSlotOwner = setCurrentSlotOwner(this.slotOwner)
196196
// set currentKeepAliveCtx so nested DynamicFragments and components can capture it
197197
const prevKeepAliveCtx = setCurrentKeepAliveCtx(keepAliveCtx)
198-
const prevBranchKey =
199-
keepAliveCtx && this.keyed
200-
? keepAliveCtx.setCurrentBranchKey(this.current)
201-
: undefined
198+
const needBranchKey = keepAliveCtx && this.keyed
199+
const prevBranchKey = needBranchKey
200+
? keepAliveCtx.setCurrentBranchKey(this.current)
201+
: undefined
202202
const prevInstance = setCurrentInstance(instance)
203203
try {
204204
this.nodes = this.scope.run(render) || []
205205
} finally {
206206
setCurrentInstance(...prevInstance)
207-
if (prevBranchKey) keepAliveCtx!.setCurrentBranchKey(prevBranchKey)
207+
if (needBranchKey) keepAliveCtx.setCurrentBranchKey(prevBranchKey)
208208
setCurrentKeepAliveCtx(prevKeepAliveCtx)
209209
setCurrentSlotOwner(prevSlotOwner)
210210
}

0 commit comments

Comments
 (0)