fix(ssr): fix ssr scopeId on component root
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ComponentInternalInstance, Slot, Slots } from 'vue'
|
||||
import { ComponentInternalInstance, Slots } from 'vue'
|
||||
import { Props, PushFn, renderVNodeChildren } from '../render'
|
||||
|
||||
export type SSRSlots = Record<string, SSRSlot>
|
||||
@@ -21,13 +21,16 @@ export function ssrRenderSlot(
|
||||
push(`<!--[-->`)
|
||||
const slotFn = slots[slotName]
|
||||
if (slotFn) {
|
||||
if (slotFn.length > 1) {
|
||||
// only ssr-optimized slot fns accept more than 1 arguments
|
||||
const scopeId = parentComponent && parentComponent.type.__scopeId
|
||||
slotFn(slotProps, push, parentComponent, scopeId ? ` ${scopeId}-s` : ``)
|
||||
} else {
|
||||
const scopeId = parentComponent && parentComponent.type.__scopeId
|
||||
const ret = slotFn(
|
||||
slotProps,
|
||||
push,
|
||||
parentComponent,
|
||||
scopeId ? ` ${scopeId}-s` : ``
|
||||
)
|
||||
if (Array.isArray(ret)) {
|
||||
// normal slot
|
||||
renderVNodeChildren(push, (slotFn as Slot)(slotProps), parentComponent)
|
||||
renderVNodeChildren(push, ret, parentComponent)
|
||||
}
|
||||
} else if (fallbackRenderFn) {
|
||||
fallbackRenderFn()
|
||||
|
||||
Reference in New Issue
Block a user