"const { ssrRenderSlotInner: _ssrRenderSlotInner } = require(\\"vue/server-renderer\\")
return function ssrRender(_ctx, _push, _parent, _attrs) {
- _ssrRenderSlotInner(_ctx.$slots, \\"default\\", {}, null, _push, _parent)
+ _ssrRenderSlotInner(_ctx.$slots, \\"default\\", {}, null, _push, _parent, null, true)
}"
`)
})
parent.children.filter(c => c.type === NodeTypes.ELEMENT).length === 1
) {
method = SSR_RENDER_SLOT_INNER
+ if (!(context.scopeId && context.slotted !== false)) {
+ args.push('null')
+ }
+ args.push('true')
}
node.ssrCodegenNode = createCallExpression(context.helper(method), args)
`<div><!--[--><!--[--><div>one</div><div>two</div><!--]--><!--]--></div>`
)
})
+
+ test('transition slot', async () => {
+ expect(
+ await renderToString(
+ createApp({
+ components: {
+ one: {
+ template: `<transition><slot/></transition>`
+ }
+ },
+ template: `<one><div v-if="false">foo</div></one>`
+ })
+ )
+ ).toBe(`<!---->`)
+
+ expect(
+ await renderToString(
+ createApp({
+ components: {
+ one: {
+ template: `<transition><slot/></transition>`
+ }
+ },
+ template: `<one><div v-if="true">foo</div></one>`
+ })
+ )
+ ).toBe(`<div>foo</div>`)
+ })
})
fallbackRenderFn: (() => void) | null,
push: PushFn,
parentComponent: ComponentInternalInstance,
- slotScopeId?: string
+ slotScopeId?: string,
+ transition?: boolean
) {
const slotFn = slots[slotName]
if (slotFn) {
// ssr slot.
// check if the slot renders all comments, in which case use the fallback
let isEmptySlot = true
- for (let i = 0; i < slotBuffer.length; i++) {
- if (!isComment(slotBuffer[i])) {
- isEmptySlot = false
- break
+ if (transition) {
+ isEmptySlot = false
+ } else {
+ for (let i = 0; i < slotBuffer.length; i++) {
+ if (!isComment(slotBuffer[i])) {
+ isEmptySlot = false
+ break
+ }
}
}
if (isEmptySlot) {