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-10-03 19:09:09 +00:00
|
|
|
import { PatchFlags } from '@vue/shared'
|
2019-09-28 00:29:20 +00:00
|
|
|
|
|
|
|
export function renderSlot(
|
2019-10-03 18:29:12 +00:00
|
|
|
slots: Record<string, Slot>,
|
2019-10-03 19:09:09 +00:00
|
|
|
name: 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-05 14:48:54 +00:00
|
|
|
// the compiler and guaranteed to be an array
|
2019-10-03 16:03:14 +00:00
|
|
|
fallback?: VNodeChildren
|
|
|
|
): VNode {
|
2019-10-03 19:09:09 +00:00
|
|
|
const slot = slots[name]
|
2019-10-03 16:03:14 +00:00
|
|
|
return (
|
|
|
|
openBlock(),
|
|
|
|
createBlock(
|
|
|
|
Fragment,
|
|
|
|
{ key: props.key },
|
2019-10-03 19:09:09 +00:00
|
|
|
slot ? slot(props) : fallback || [],
|
|
|
|
slots._compiled ? 0 : PatchFlags.BAIL
|
2019-10-03 16:03:14 +00:00
|
|
|
)
|
|
|
|
)
|
2019-09-28 00:29:20 +00:00
|
|
|
}
|