( slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string, transition?: boolean, )
| 41 | } |
| 42 | |
| 43 | export function ssrRenderSlotInner( |
| 44 | slots: Slots | SSRSlots, |
| 45 | slotName: string, |
| 46 | slotProps: Props, |
| 47 | fallbackRenderFn: (() => void) | null, |
| 48 | push: PushFn, |
| 49 | parentComponent: ComponentInternalInstance, |
| 50 | slotScopeId?: string, |
| 51 | transition?: boolean, |
| 52 | ): void { |
| 53 | const slotFn = slots[slotName] |
| 54 | if (slotFn) { |
| 55 | const slotBuffer: SSRBufferItem[] = [] |
| 56 | const bufferedPush = (item: SSRBufferItem) => { |
| 57 | slotBuffer.push(item) |
| 58 | } |
| 59 | const ret = slotFn( |
| 60 | slotProps, |
| 61 | bufferedPush, |
| 62 | parentComponent, |
| 63 | slotScopeId ? ' ' + slotScopeId : '', |
| 64 | ) |
| 65 | if (isArray(ret)) { |
| 66 | const validSlotContent = ensureValidVNode(ret) |
| 67 | if (validSlotContent) { |
| 68 | // normal slot |
| 69 | renderVNodeChildren( |
| 70 | push, |
| 71 | validSlotContent, |
| 72 | parentComponent, |
| 73 | slotScopeId, |
| 74 | ) |
| 75 | } else if (fallbackRenderFn) { |
| 76 | fallbackRenderFn() |
| 77 | } else if (transition) { |
| 78 | push(`<!---->`) |
| 79 | } |
| 80 | } else { |
| 81 | // ssr slot. |
| 82 | // check if the slot renders all comments, in which case use the fallback |
| 83 | let isEmptySlot = true |
| 84 | if (transition) { |
| 85 | isEmptySlot = false |
| 86 | } else { |
| 87 | for (let i = 0; i < slotBuffer.length; i++) { |
| 88 | if (!isComment(slotBuffer[i])) { |
| 89 | isEmptySlot = false |
| 90 | break |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | if (isEmptySlot) { |
| 95 | if (fallbackRenderFn) { |
| 96 | fallbackRenderFn() |
| 97 | } |
| 98 | } else { |
| 99 | // #9933 |
| 100 | // Although we handle Transition/TransitionGroup in the transform stage |
no test coverage detected