2019-09-28 00:29:20 +00:00
|
|
|
import { Slot } from '../componentSlots'
|
2019-10-03 16:03:14 +00:00
|
|
|
import {
|
|
|
|
VNodeChildren,
|
|
|
|
openBlock,
|
|
|
|
createBlock,
|
|
|
|
Fragment,
|
|
|
|
VNode
|
|
|
|
} from '../vnode'
|
2019-09-28 00:29:20 +00:00
|
|
|
|
|
|
|
export function renderSlot(
|
2019-10-03 18:29:12 +00:00
|
|
|
slots: Record<string, Slot>,
|
|
|
|
key: string,
|
2019-09-28 00:29:20 +00:00
|
|
|
props: any = {},
|
|
|
|
// this is not a user-facing function, so the fallback is always generated by
|
2019-10-03 16:03:14 +00:00
|
|
|
// the compiler and gurunteed to be an array
|
|
|
|
fallback?: VNodeChildren
|
|
|
|
): VNode {
|
2019-10-03 18:29:12 +00:00
|
|
|
const slot = slots[key]
|
2019-10-03 16:03:14 +00:00
|
|
|
return (
|
|
|
|
openBlock(),
|
|
|
|
createBlock(
|
|
|
|
Fragment,
|
|
|
|
{ key: props.key },
|
|
|
|
slot ? slot(props) : fallback || []
|
|
|
|
)
|
|
|
|
)
|
2019-09-28 00:29:20 +00:00
|
|
|
}
|