fix(transition/ssr): make transition appear work with Suspense in SSR (#12047)

close #12046
This commit is contained in:
edison 2024-10-11 10:34:28 +08:00 committed by GitHub
parent e0a591e1cd
commit f1a4f67aed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 1 deletions

View File

@ -1613,6 +1613,36 @@ describe('SSR hydration', () => {
`)
})
test('Suspense + transition appear', async () => {
const { vnode, container } = mountWithHydration(
`<template><div>foo</div></template>`,
() =>
h(Suspense, {}, () =>
h(
Transition,
{ appear: true },
{
default: () => h('div', 'foo'),
},
),
),
)
expect(vnode.el).toBe(container.firstChild)
// wait for hydration to finish
await new Promise(r => setTimeout(r))
expect(container.firstChild).toMatchInlineSnapshot(`
<div
class="v-enter-from v-enter-active"
>
foo
</div>
`)
await nextTick()
expect(vnode.el).toBe(container.firstChild)
})
// #10607
test('update component stable slot (prod + optimized mode)', async () => {
__DEV__ = false

View File

@ -385,7 +385,10 @@ export function createHydrationFunctions(
let needCallTransitionHooks = false
if (isTemplateNode(el)) {
needCallTransitionHooks =
needTransition(parentSuspense, transition) &&
needTransition(
null, // no need check parentSuspense in hydration
transition,
) &&
parentComponent &&
parentComponent.vnode.props &&
parentComponent.vnode.props.appear