31 lines
685 B
TypeScript
31 lines
685 B
TypeScript
import { Data } from '../component'
|
|
import { Slot } from '../componentSlots'
|
|
import {
|
|
VNodeChildren,
|
|
openBlock,
|
|
createBlock,
|
|
Fragment,
|
|
VNode
|
|
} from '../vnode'
|
|
import { PatchFlags } from '@vue/shared'
|
|
|
|
export function renderSlot(
|
|
slots: Record<string, Slot>,
|
|
name: string,
|
|
props: Data = {},
|
|
// this is not a user-facing function, so the fallback is always generated by
|
|
// the compiler and guaranteed to be an array
|
|
fallback?: VNodeChildren
|
|
): VNode {
|
|
const slot = slots[name]
|
|
return (
|
|
openBlock(),
|
|
createBlock(
|
|
Fragment,
|
|
{ key: props.key },
|
|
slot ? slot(props) : fallback || [],
|
|
slots._compiled ? 0 : PatchFlags.BAIL
|
|
)
|
|
)
|
|
}
|