- v-model and v-show directives are now exposed as public - compiler-used runtime helpers are now exposed for TS tooling, but marked as @private close #1329
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
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/>
|
|
* @private
|
|
*/
|
|
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
|
|
)
|
|
)
|
|
}
|