Skip to content

Commit

Permalink
fix: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoErii committed Apr 17, 2024
1 parent 3624393 commit 9ae6212
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions packages/runtime-core/src/components/BaseTransition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { ErrorCodes, callWithAsyncErrorHandling } from '../errorHandling'
import { PatchFlags, ShapeFlags, isArray } from '@vue/shared'
import { onBeforeUnmount, onMounted } from '../apiLifecycle'
import type { RendererElement } from '../renderer'
import type { RawSlots, Slot } from '../componentSlots'

type Hook<T = () => void> = T | T[]

Expand Down Expand Up @@ -460,16 +459,24 @@ function emptyPlaceholder(vnode: VNode): VNode | undefined {
}

function getKeepAliveChild(vnode: VNode): VNode | undefined {
return isKeepAlive(vnode)
? // #7121 ensure get the child component subtree in case
// it's been replaced during HMR
__DEV__ && vnode.component
? vnode.component.subTree
: vnode.children
? ((vnode.children as VNodeArrayChildren)[0] as VNode) ||
((vnode.children as RawSlots).default as Slot)?.()
: undefined
: vnode
if (!isKeepAlive(vnode)) {
return vnode
}
// #7121 ensure get the child component subtree in case
// it's been replaced during HMR
if (__DEV__ && vnode.component) {
return vnode.component.subTree
}

if (vnode.shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
return (vnode.children as VNodeArrayChildren)?.[0] as VNode
}

if (vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
return (vnode.children as any)?.default?.()
}

return undefined
}

export function setTransitionHooks(vnode: VNode, hooks: TransitionHooks) {
Expand Down

0 comments on commit 9ae6212

Please sign in to comment.