| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import { Data } from '../component'
- import { Slots } from '../componentSlots'
- import {
- VNodeArrayChildren,
- openBlock,
- createBlock,
- Fragment,
- VNode
- } from '../vnode'
- import { PatchFlags } from '@vue/shared'
- import { warn } from '../warning'
- /**
- * Compiler runtime helper for rendering <slot/>
- * @internal
- */
- export function renderSlot(
- slots: Slots,
- name: string,
- props: Data = {},
- // this is not a user-facing function, so the fallback is always generated by
- // the compiler and guaranteed to be a function returning an array
- fallback?: () => VNodeArrayChildren
- ): VNode {
- let slot = slots[name]
- if (__DEV__ && slot && slot.length > 1) {
- warn(
- `SSR-optimized slot function detected in a non-SSR-optimized render ` +
- `function. You need to mark this component with $dynamic-slots in the ` +
- `parent template.`
- )
- slot = () => []
- }
- return (
- openBlock(),
- createBlock(
- Fragment,
- { key: props.key },
- slot ? slot(props) : fallback ? fallback() : [],
- slots._ ? PatchFlags.STABLE_FRAGMENT : PatchFlags.BAIL
- )
- )
- }
|