Skip to content

Commit

Permalink
fix(runtime-core): switch suspense cause error in the Keepalive (fix: v…
Browse files Browse the repository at this point in the history
  • Loading branch information
hoi-lau committed Oct 25, 2022
1 parent b0b74a1 commit 02c7020
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/runtime-core/src/components/Suspense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,20 @@ function patchSuspense(
slotScopeIds,
optimized
)
let shapeFlag = newBranch.shapeFlag
let asyncResolved = true
let vnode = newBranch
const keepAlive = !!(shapeFlag & ShapeFlags.COMPONENT_KEPT_ALIVE)
while (keepAlive && shapeFlag & ShapeFlags.COMPONENT && vnode.component) {
asyncResolved = vnode.component.asyncResolved
if (!asyncResolved) {
vnode.component.suspenseId = suspense.pendingId
suspense.deps++
break
}
vnode = vnode.component.subTree
shapeFlag = vnode.shapeFlag
}
if (suspense.deps <= 0) {
// incoming branch has no async deps, resolve now.
suspense.resolve()
Expand All @@ -346,7 +360,7 @@ function patchSuspense(
suspense.fallback(newFallback)
}
}, timeout)
} else if (timeout === 0) {
} else if (timeout === 0 || !asyncResolved) {
suspense.fallback(newFallback)
}
}
Expand Down

0 comments on commit 02c7020

Please sign in to comment.