From cb31eb4d0a0afdd2abf9e3897d9aac447dd0264b Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 25 Mar 2020 15:08:15 -0400 Subject: [PATCH] feat(runtime-core): failed component resolution should fallback to native element --- .../runtime-core/src/helpers/resolveAssets.ts | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/packages/runtime-core/src/helpers/resolveAssets.ts b/packages/runtime-core/src/helpers/resolveAssets.ts index efc85dd30e6..fe38ef887a3 100644 --- a/packages/runtime-core/src/helpers/resolveAssets.ts +++ b/packages/runtime-core/src/helpers/resolveAssets.ts @@ -1,10 +1,5 @@ import { currentRenderingInstance } from '../componentRenderUtils' -import { - currentInstance, - Component, - ComponentInternalInstance, - FunctionalComponent -} from '../component' +import { currentInstance, Component, FunctionalComponent } from '../component' import { Directive } from '../directives' import { camelize, @@ -18,8 +13,8 @@ import { warn } from '../warning' const COMPONENTS = 'components' const DIRECTIVES = 'directives' -export function resolveComponent(name: string): Component | undefined { - return resolveAsset(COMPONENTS, name) +export function resolveComponent(name: string): Component | string | undefined { + return resolveAsset(COMPONENTS, name) || name } export function resolveDynamicComponent( @@ -27,11 +22,7 @@ export function resolveDynamicComponent( ): Component | string | undefined { if (!component) return if (isString(component)) { - return ( - resolveAsset(COMPONENTS, component, currentRenderingInstance, false) || - // fallback to plain element - component - ) + return resolveAsset(COMPONENTS, component, false) || component } else if (isFunction(component) || isObject(component)) { return component } @@ -45,23 +36,20 @@ export function resolveDirective(name: string): Directive | undefined { function resolveAsset( type: typeof COMPONENTS, name: string, - instance?: ComponentInternalInstance | null, warnMissing?: boolean ): Component | undefined // overload 2: directives function resolveAsset( type: typeof DIRECTIVES, - name: string, - instance?: ComponentInternalInstance | null + name: string ): Directive | undefined function resolveAsset( type: typeof COMPONENTS | typeof DIRECTIVES, name: string, - instance: ComponentInternalInstance | null = currentRenderingInstance || - currentInstance, warnMissing = true ) { + const instance = currentRenderingInstance || currentInstance if (instance) { let camelized, capitalized const registry = instance[type]