feat(compiler): transform slot outlets
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
import { ComponentInternalInstance, currentInstance } from './component'
|
||||
import { VNode, NormalizedChildren, normalizeVNode, VNodeChild } from './vnode'
|
||||
import {
|
||||
VNode,
|
||||
NormalizedChildren,
|
||||
normalizeVNode,
|
||||
VNodeChild,
|
||||
VNodeChildren
|
||||
} from './vnode'
|
||||
import { isArray, isFunction } from '@vue/shared'
|
||||
import { ShapeFlags } from './shapeFlags'
|
||||
import { warn } from './warning'
|
||||
|
||||
export type Slot = (...args: any[]) => VNode[]
|
||||
export type Slot = (...args: any[]) => VNodeChildren
|
||||
export type Slots = Readonly<{
|
||||
[name: string]: Slot
|
||||
}>
|
||||
|
||||
12
packages/runtime-core/src/helpers/renderSlot.ts
Normal file
12
packages/runtime-core/src/helpers/renderSlot.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Slot } from '../componentSlots'
|
||||
import { VNodeChildren } from '../vnode'
|
||||
|
||||
export function renderSlot(
|
||||
slot: Slot | undefined,
|
||||
props: any = {},
|
||||
// this is not a user-facing function, so the fallback is always generated by
|
||||
// the compiler.
|
||||
fallback?: string | VNodeChildren
|
||||
): string | VNodeChildren | null {
|
||||
return slot ? slot() : fallback || null
|
||||
}
|
||||
@@ -42,6 +42,7 @@ export { resolveComponent, resolveDirective } from './helpers/resolveAssets'
|
||||
export { renderList } from './helpers/renderList'
|
||||
export { toString } from './helpers/toString'
|
||||
export { toHandlers } from './helpers/toHandlers'
|
||||
export { renderSlot } from './helpers/renderSlot'
|
||||
export { capitalize, camelize } from '@vue/shared'
|
||||
|
||||
// Internal, for integration with runtime compiler
|
||||
|
||||
Reference in New Issue
Block a user