|
@@ -11,6 +11,7 @@ import {
|
|
|
checkTransitionMode,
|
|
checkTransitionMode,
|
|
|
currentInstance,
|
|
currentInstance,
|
|
|
getComponentName,
|
|
getComponentName,
|
|
|
|
|
+ isAsyncWrapper,
|
|
|
isTemplateNode,
|
|
isTemplateNode,
|
|
|
leaveCbKey,
|
|
leaveCbKey,
|
|
|
queuePostFlushCb,
|
|
queuePostFlushCb,
|
|
@@ -92,7 +93,7 @@ export const VaporTransition: FunctionalVaporComponent = /*@__PURE__*/ decorate(
|
|
|
if (child) {
|
|
if (child) {
|
|
|
// replace existing transition hooks
|
|
// replace existing transition hooks
|
|
|
child.$transition!.props = resolvedProps
|
|
child.$transition!.props = resolvedProps
|
|
|
- applyTransitionHooks(child, child.$transition!)
|
|
|
|
|
|
|
+ applyTransitionHooks(child, child.$transition!, undefined, true)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
@@ -141,7 +142,7 @@ export const VaporTransition: FunctionalVaporComponent = /*@__PURE__*/ decorate(
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const getTransitionHooksContext = (
|
|
const getTransitionHooksContext = (
|
|
|
- key: String,
|
|
|
|
|
|
|
+ key: string,
|
|
|
props: TransitionProps,
|
|
props: TransitionProps,
|
|
|
state: TransitionState,
|
|
state: TransitionState,
|
|
|
instance: GenericComponentInstance,
|
|
instance: GenericComponentInstance,
|
|
@@ -210,6 +211,7 @@ export function applyTransitionHooks(
|
|
|
block: Block,
|
|
block: Block,
|
|
|
hooks: VaporTransitionHooks,
|
|
hooks: VaporTransitionHooks,
|
|
|
fallthroughAttrs: boolean = true,
|
|
fallthroughAttrs: boolean = true,
|
|
|
|
|
+ isResolved: boolean = false,
|
|
|
): VaporTransitionHooks {
|
|
): VaporTransitionHooks {
|
|
|
// filter out comment nodes
|
|
// filter out comment nodes
|
|
|
if (isArray(block)) {
|
|
if (isArray(block)) {
|
|
@@ -222,7 +224,9 @@ export function applyTransitionHooks(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const isFrag = isFragment(block)
|
|
const isFrag = isFragment(block)
|
|
|
- const child = findTransitionBlock(block, isFrag)
|
|
|
|
|
|
|
+ const child = isResolved
|
|
|
|
|
+ ? (block as TransitionBlock)
|
|
|
|
|
+ : findTransitionBlock(block, isFrag)
|
|
|
if (!child) {
|
|
if (!child) {
|
|
|
// set transition hooks on fragment for reusing during it's updating
|
|
// set transition hooks on fragment for reusing during it's updating
|
|
|
if (isFrag) setTransitionHooksOnFragment(block, hooks)
|
|
if (isFrag) setTransitionHooksOnFragment(block, hooks)
|
|
@@ -238,7 +242,7 @@ export function applyTransitionHooks(
|
|
|
hooks => (resolvedHooks = hooks as VaporTransitionHooks),
|
|
hooks => (resolvedHooks = hooks as VaporTransitionHooks),
|
|
|
)
|
|
)
|
|
|
resolvedHooks.delayedLeave = delayedLeave
|
|
resolvedHooks.delayedLeave = delayedLeave
|
|
|
- setTransitionHooks(child, resolvedHooks)
|
|
|
|
|
|
|
+ child.$transition = resolvedHooks
|
|
|
if (isFrag) setTransitionHooksOnFragment(block, resolvedHooks)
|
|
if (isFrag) setTransitionHooksOnFragment(block, resolvedHooks)
|
|
|
|
|
|
|
|
// fallthrough attrs
|
|
// fallthrough attrs
|
|
@@ -266,7 +270,7 @@ export function applyTransitionLeaveHooks(
|
|
|
state,
|
|
state,
|
|
|
instance,
|
|
instance,
|
|
|
)
|
|
)
|
|
|
- setTransitionHooks(leavingBlock, leavingHooks)
|
|
|
|
|
|
|
+ leavingBlock.$transition = leavingHooks
|
|
|
|
|
|
|
|
const { mode } = props
|
|
const { mode } = props
|
|
|
if (mode === 'out-in') {
|
|
if (mode === 'out-in') {
|
|
@@ -300,25 +304,25 @@ export function applyTransitionLeaveHooks(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const transitionBlockCache = new WeakMap<Block, TransitionBlock>()
|
|
|
|
|
export function findTransitionBlock(
|
|
export function findTransitionBlock(
|
|
|
block: Block,
|
|
block: Block,
|
|
|
inFragment: boolean = false,
|
|
inFragment: boolean = false,
|
|
|
): TransitionBlock | undefined {
|
|
): TransitionBlock | undefined {
|
|
|
- if (transitionBlockCache.has(block)) {
|
|
|
|
|
- return transitionBlockCache.get(block)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
let child: TransitionBlock | undefined
|
|
let child: TransitionBlock | undefined
|
|
|
if (block instanceof Node) {
|
|
if (block instanceof Node) {
|
|
|
// transition can only be applied on Element child
|
|
// transition can only be applied on Element child
|
|
|
if (block instanceof Element) child = block
|
|
if (block instanceof Element) child = block
|
|
|
} else if (isVaporComponent(block)) {
|
|
} else if (isVaporComponent(block)) {
|
|
|
- // stop searching if encountering nested Transition component
|
|
|
|
|
- if (getComponentName(block.type) === displayName) return undefined
|
|
|
|
|
- child = findTransitionBlock(block.block, inFragment)
|
|
|
|
|
- // use component id as key
|
|
|
|
|
- if (child && child.$key === undefined) child.$key = block.uid
|
|
|
|
|
|
|
+ // should save hooks on unresolved async wrapper, so that it can be applied after resolved
|
|
|
|
|
+ if (isAsyncWrapper(block) && !block.type.__asyncResolved) {
|
|
|
|
|
+ child = block
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // stop searching if encountering nested Transition component
|
|
|
|
|
+ if (getComponentName(block.type) === displayName) return undefined
|
|
|
|
|
+ child = findTransitionBlock(block.block, inFragment)
|
|
|
|
|
+ // use component id as key
|
|
|
|
|
+ if (child && child.$key === undefined) child.$key = block.uid
|
|
|
|
|
+ }
|
|
|
} else if (isArray(block)) {
|
|
} else if (isArray(block)) {
|
|
|
let hasFound = false
|
|
let hasFound = false
|
|
|
for (const c of block) {
|
|
for (const c of block) {
|
|
@@ -369,7 +373,7 @@ export function setTransitionHooksOnFragment(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export function setTransitionHooks(
|
|
export function setTransitionHooks(
|
|
|
- block: TransitionBlock | VaporComponentInstance,
|
|
|
|
|
|
|
+ block: TransitionBlock,
|
|
|
hooks: VaporTransitionHooks,
|
|
hooks: VaporTransitionHooks,
|
|
|
): void {
|
|
): void {
|
|
|
if (isVaporComponent(block)) {
|
|
if (isVaporComponent(block)) {
|