mirror of https://github.com/vuejs/core.git
Merge 7fa4403692
into bb4ae25793
This commit is contained in:
commit
5e8787216d
|
@ -28,6 +28,7 @@ export enum ErrorCodes {
|
|||
SCHEDULER,
|
||||
COMPONENT_UPDATE,
|
||||
APP_UNMOUNT_CLEANUP,
|
||||
RENDER_SLOTS,
|
||||
}
|
||||
|
||||
export const ErrorTypeStrings: Record<ErrorTypes, string> = {
|
||||
|
@ -62,6 +63,7 @@ export const ErrorTypeStrings: Record<ErrorTypes, string> = {
|
|||
[ErrorCodes.SCHEDULER]: 'scheduler flush',
|
||||
[ErrorCodes.COMPONENT_UPDATE]: 'component update',
|
||||
[ErrorCodes.APP_UNMOUNT_CLEANUP]: 'app unmount cleanup function',
|
||||
[ErrorCodes.RENDER_SLOTS]: 'render slots',
|
||||
}
|
||||
|
||||
export type ErrorTypes = LifecycleHooks | ErrorCodes | WatchErrorCodes
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {
|
||||
Fragment,
|
||||
type Ref,
|
||||
inject,
|
||||
nextTick,
|
||||
|
@ -352,4 +353,16 @@ describe('component', () => {
|
|||
'Vapor component setup() returned non-block value, and has no render function',
|
||||
).toHaveBeenWarned()
|
||||
})
|
||||
|
||||
it('Fragment slots should be rendered', () => {
|
||||
const { host } = define({
|
||||
setup() {
|
||||
return createComponent(Fragment as any, null, {
|
||||
default: () => template('HI', true)(),
|
||||
})
|
||||
},
|
||||
}).render()
|
||||
|
||||
expect(host.innerHTML).toBe('HI')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -5,6 +5,7 @@ import {
|
|||
type EmitFn,
|
||||
type EmitsOptions,
|
||||
ErrorCodes,
|
||||
Fragment,
|
||||
type GenericAppContext,
|
||||
type GenericComponentInstance,
|
||||
type LifecycleHook,
|
||||
|
@ -213,7 +214,18 @@ export function createComponent(
|
|||
]) || EMPTY_OBJ
|
||||
: EMPTY_OBJ
|
||||
|
||||
if (__DEV__ && !isBlock(setupResult)) {
|
||||
if (component === Fragment && rawSlots) {
|
||||
const defaultSlot = getSlot(rawSlots as RawSlots, 'default')
|
||||
if (defaultSlot) {
|
||||
instance.block = callWithErrorHandling(
|
||||
defaultSlot,
|
||||
instance,
|
||||
ErrorCodes.RENDER_SLOTS,
|
||||
)
|
||||
} else {
|
||||
instance.block = []
|
||||
}
|
||||
} else if (__DEV__ && !isBlock(setupResult)) {
|
||||
if (isFunction(component)) {
|
||||
warn(`Functional vapor component must return a block directly.`)
|
||||
instance.block = []
|
||||
|
|
Loading…
Reference in New Issue