fix(build): fix component resolution when disabling options API
fix #1688
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { currentRenderingInstance } from '../componentRenderUtils'
|
||||
import { currentInstance, Component, FunctionalComponent } from '../component'
|
||||
import {
|
||||
currentInstance,
|
||||
Component,
|
||||
FunctionalComponent,
|
||||
ComponentOptions
|
||||
} from '../component'
|
||||
import { Directive } from '../directives'
|
||||
import { camelize, capitalize, isString } from '@vue/shared'
|
||||
import { warn } from '../warning'
|
||||
@@ -58,24 +63,27 @@ function resolveAsset(
|
||||
) {
|
||||
const instance = currentRenderingInstance || currentInstance
|
||||
if (instance) {
|
||||
let camelized, capitalized
|
||||
const registry = instance[type]
|
||||
let res =
|
||||
registry[name] ||
|
||||
registry[(camelized = camelize(name))] ||
|
||||
registry[(capitalized = capitalize(camelized))]
|
||||
if (!res && type === COMPONENTS) {
|
||||
const self = instance.type
|
||||
const selfName = (self as FunctionalComponent).displayName || self.name
|
||||
const Component = instance.type
|
||||
|
||||
// self name has highest priority
|
||||
if (type === COMPONENTS) {
|
||||
const selfName =
|
||||
(Component as FunctionalComponent).displayName || Component.name
|
||||
if (
|
||||
selfName &&
|
||||
(selfName === name ||
|
||||
selfName === camelized ||
|
||||
selfName === capitalized)
|
||||
selfName === camelize(name) ||
|
||||
selfName === capitalize(camelize(name)))
|
||||
) {
|
||||
res = self
|
||||
return Component
|
||||
}
|
||||
}
|
||||
|
||||
const res =
|
||||
// local registration
|
||||
resolve((Component as ComponentOptions)[type], name) ||
|
||||
// global registration
|
||||
resolve(instance.appContext[type], name)
|
||||
if (__DEV__ && warnMissing && !res) {
|
||||
warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`)
|
||||
}
|
||||
@@ -87,3 +95,12 @@ function resolveAsset(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function resolve(registry: Record<string, any> | undefined, name: string) {
|
||||
return (
|
||||
registry &&
|
||||
(registry[name] ||
|
||||
registry[camelize(name)] ||
|
||||
registry[capitalize(camelize(name))])
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user