| 23 | * @private |
| 24 | */ |
| 25 | export function renderSlot( |
| 26 | slots: Slots, |
| 27 | name: string, |
| 28 | props: Data = {}, |
| 29 | // this is not a user-facing function, so the fallback is always generated by |
| 30 | // the compiler and guaranteed to be a function returning an array |
| 31 | fallback?: () => VNodeArrayChildren, |
| 32 | noSlotted?: boolean, |
| 33 | ): VNode { |
| 34 | if ( |
| 35 | currentRenderingInstance!.ce || |
| 36 | (currentRenderingInstance!.parent && |
| 37 | isAsyncWrapper(currentRenderingInstance!.parent) && |
| 38 | currentRenderingInstance!.parent.ce) |
| 39 | ) { |
| 40 | const hasProps = Object.keys(props).length > 0 |
| 41 | // in custom element mode, render <slot/> as actual slot outlets |
| 42 | // wrap it with a fragment because in shadowRoot: false mode the slot |
| 43 | // element gets replaced by injected content |
| 44 | if (name !== 'default') props.name = name |
| 45 | return ( |
| 46 | openBlock(), |
| 47 | createBlock( |
| 48 | Fragment, |
| 49 | null, |
| 50 | [createVNode('slot', props, fallback && fallback())], |
| 51 | hasProps ? PatchFlags.BAIL : PatchFlags.STABLE_FRAGMENT, |
| 52 | ) |
| 53 | ) |
| 54 | } |
| 55 | |
| 56 | let slot = slots[name] |
| 57 | |
| 58 | if (__DEV__ && slot && slot.length > 1) { |
| 59 | warn( |
| 60 | `SSR-optimized slot function detected in a non-SSR-optimized render ` + |
| 61 | `function. You need to mark this component with $dynamic-slots in the ` + |
| 62 | `parent template.`, |
| 63 | ) |
| 64 | slot = () => [] |
| 65 | } |
| 66 | |
| 67 | // a compiled slot disables block tracking by default to avoid manual |
| 68 | // invocation interfering with template-based block tracking, but in |
| 69 | // `renderSlot` we can be sure that it's template-based so we can force |
| 70 | // enable it. |
| 71 | if (slot && (slot as ContextualRenderFn)._c) { |
| 72 | ;(slot as ContextualRenderFn)._d = false |
| 73 | } |
| 74 | openBlock() |
| 75 | const validSlotContent = slot && ensureValidVNode(slot(props)) |
| 76 | const slotKey = |
| 77 | props.key || |
| 78 | // slot content array of a dynamic conditional slot may have a branch |
| 79 | // key attached in the `createSlots` helper, respect that |
| 80 | (validSlotContent && (validSlotContent as any).key) |
| 81 | const rendered = createBlock( |
| 82 | Fragment, |