Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
30 changes: 30 additions & 0 deletions packages/runtime-core/__tests__/hydration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions packages/runtime-core/src/hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
normalizeStyle,
stringifyStyle,
} from '@vue/shared'
import { type RendererInternals, needTransition } from './renderer'
import type { RendererInternals } from './renderer'
import { setRef } from './rendererTemplateRef'
import {
type SuspenseBoundary,
Expand Down Expand Up @@ -385,7 +385,8 @@ export function createHydrationFunctions(
let needCallTransitionHooks = false
if (isTemplateNode(el)) {
needCallTransitionHooks =
needTransition(parentSuspense, transition) &&
transition &&
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to check parentSuspense during hydration.

!transition.persisted &&
parentComponent &&
parentComponent.vnode.props &&
parentComponent.vnode.props.appear
Expand Down