fix(runtime-core): dynamic component should support falsy values without warning
This commit is contained in:
@@ -6,13 +6,7 @@ import {
|
||||
ComponentOptions
|
||||
} from '../component'
|
||||
import { Directive } from '../directives'
|
||||
import {
|
||||
camelize,
|
||||
capitalize,
|
||||
isString,
|
||||
isObject,
|
||||
isFunction
|
||||
} from '@vue/shared'
|
||||
import { camelize, capitalize, isString, isObject } from '@vue/shared'
|
||||
import { warn } from '../warning'
|
||||
|
||||
const COMPONENTS = 'components'
|
||||
@@ -22,14 +16,16 @@ export function resolveComponent(name: string): Component | string | undefined {
|
||||
return resolveAsset(COMPONENTS, name) || name
|
||||
}
|
||||
|
||||
export const NULL_DYNAMIC_COMPONENT = Symbol()
|
||||
|
||||
export function resolveDynamicComponent(
|
||||
component: unknown
|
||||
): Component | string | undefined {
|
||||
if (!component) return
|
||||
): Component | string | typeof NULL_DYNAMIC_COMPONENT {
|
||||
if (isString(component)) {
|
||||
return resolveAsset(COMPONENTS, component, false) || component
|
||||
} else if (isFunction(component) || isObject(component)) {
|
||||
return component
|
||||
} else {
|
||||
// invalid types will fallthrough to createVNode and raise warning
|
||||
return (component as any) || NULL_DYNAMIC_COMPONENT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user