Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/runtime-vapor/__tests__/components/Transition.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3799,6 +3799,8 @@ describe('a child rendering its root after the hooks were applied, like vdom', (
content: string,
init: Record<string, any>,
steps: Step[],
// the Transition stays vdom: its hooks are relayed to the vapor child
vdomHost = false,
) {
const srcs: Record<string, string> = {
Item: `<template><div class="item">item</div></template>`,
Expand Down Expand Up @@ -3848,7 +3850,7 @@ describe('a child rendering its root after the hooks were applied, like vdom', (
: `<script setup>const data = _data; const components = _components;</script>` +
srcs[name]
components[name] = compile(src, data, components, {
vapor: vapor && name !== 'App',
vapor: vapor && name !== 'App' && !(vdomHost && name === 'Host'),
})
}
const load = () => Promise.resolve(components.Item)
Expand Down Expand Up @@ -3909,4 +3911,16 @@ describe('a child rendering its root after the hooks were applied, like vdom', (
['ready', 'off', 'done'],
),
)

describe.each(['out-in', 'in-out', 'default'])(
'under a vdom Transition, %s',
mode => {
test.each([
['an async setup component', children['an async setup component']],
['a component rooted in one', children['a component rooted in one']],
])('%s enters once its setup resolves', (_, content) =>
parity(mode, content, { show: false }, ['on', 'done'], true),
)
},
)
})
11 changes: 7 additions & 4 deletions packages/runtime-vapor/src/components/Transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,8 @@ function collectComponentTransitionBlocks(
block.asyncDep &&
!block.asyncResolved
) {
if (ctx) {
if (onFragment) onFragment(block)
if (onFragment) {
onFragment(block)
resolveRootAfterSetup(block, ctx)
}
return
Expand Down Expand Up @@ -1181,9 +1181,10 @@ function collectComponentTransitionBlocks(
collectTransitionBlocks(block.block, onFragment, children, ctx)
}

// `ctx` undefined: hooks relayed from a vdom Transition, resolving no identity
function resolveRootAfterSetup(
instance: VaporComponentInstance & TransitionOptions,
ctx: KeyContext,
ctx: KeyContext | undefined,
): void {
// one callback per instance: a later walk only updates the context it uses
if (!keyContexts.has(instance)) {
Expand All @@ -1200,8 +1201,10 @@ function resolveRootAfterSetup(
)
}
})
keyContexts.set(instance, ctx || ROOT_KEY_CONTEXT)
} else if (ctx) {
keyContexts.set(instance, ctx)
}
keyContexts.set(instance, ctx)
}

function collectArrayTransitionBlocks(
Expand Down
Loading