8000 fix(ssr): properly init slots during ssr rendering by edison1105 · Pull Request #12441 · vuejs/core · GitHub
[go: up one dir, main page]

Skip to content

fix(ssr): properly init slots during ssr rendering #12441

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

Merged
merged 4 commits into from
May 2, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test: add test case
  • Loading branch information
edison1105 committed Nov 20, 2024
commit 659c0bfc908605b078cd852a167edabeb4280c9f
34 changes: 33 additions & 1 deletion packages/server-renderer/__tests__/ssrSlot.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createApp } from 'vue'
import { createApp, defineAsyncComponent, h } from 'vue'
import { renderToString } from '../src/renderToString'

const components = {
Expand Down Expand Up @@ -154,6 +154,38 @@ describe('ssr: slot', () => {
).toBe(`<div><p>1</p><p>2</p></div>`)
})

// #12438
test('async component slot with v-if true', async () => {
const Layout = defineAsyncComponent(() =>
Promise.resolve({
template: `<div><slot name="header">default header</slot></div>`,
}),
)
const LayoutLoader = {
setup(_: any, context: any) {
return () => h(Layout, {}, context.slots)
},
}
expect(
await renderToString(
createApp({
components: {
LayoutLoader,
},
template: `
<Suspense>
<LayoutLoader>
<template v-if="true" #header>
new header
</template>
</LayoutLoader>
</Suspense>
`,
}),
),
).toBe(`<div><!--[--> new header <!--]--></div>`)
})

// #11326
test('dynamic component slot', async () => {
expect(
Expand Down
0