11import {
2+ type ComponentInternalInstance ,
3+ type ComponentInternalOptions ,
24 type ComponentOptions ,
35 type ConcreteComponent ,
46 currentInstance ,
57 getComponentName ,
68} from '../component'
79import { currentRenderingInstance } from '../componentRenderContext'
810import type { Directive } from '../directives'
9- import { camelize , capitalize , isString } from '@vue/shared'
11+ import { camelize , capitalize , isLateTag , isString } from '@vue/shared'
1012import { warn } from '../warning'
1113import type { VNodeTypes } from '../vnode'
1214
@@ -106,18 +108,26 @@ function resolveAsset(
106108 resolve ( instance [ type ] || ( Component as ComponentOptions ) [ type ] , name ) ||
107109 // global registration
108110 resolve ( instance . appContext [ type ] , name )
109-
110111 if ( ! res && maybeSelfReference ) {
111112 // fallback to implicit self-reference
112113 return Component
113114 }
114115
115- if ( __DEV__ && warnMissing && ! res ) {
116- const extra =
117- type === COMPONENTS
118- ? `\nIf this is a native custom element, make sure to exclude it from ` +
116+ if (
117+ __DEV__ &&
118+ warnMissing &&
119+ ( ( ! res && ! isLateTag ( name ) ) || ( res && isLateTag ( name ) ) )
120+ ) {
121+ let extra = ''
122+ if ( type === COMPONENTS ) {
123+ if ( isLateTag ( name ) ) {
124+ extra = `\nplease do not use built-in tag names as component names.`
125+ } else {
126+ extra =
127+ `\nIf this is a native custom element, make sure to exclude it from ` +
119128 `component resolution via compilerOptions.isCustomElement.`
120- : ``
129+ }
130+ }
121131 warn ( `Failed to resolve ${ type . slice ( 0 , - 1 ) } : ${ name } ${ extra } ` )
122132 }
123133
@@ -138,3 +148,23 @@ function resolve(registry: Record<string, any> | undefined, name: string) {
138148 registry [ capitalize ( camelize ( name ) ) ] )
139149 )
140150}
151+
152+ /**
153+ * @private
154+ */
155+ export function resolveSetupReturned (
156+ name : string ,
157+ setupReturn : ComponentInternalInstance [ 'setupState' ] ,
158+ ) : unknown {
159+ if ( ! setupReturn ) return name
160+ const returnValue = setupReturn [ name ]
161+ if (
162+ returnValue &&
163+ ( returnValue as ComponentInternalOptions ) . __file &&
164+ isLateTag ( name as string )
165+ ) {
166+ const extra = `\nplease do not use built-in tag names as component names.`
167+ warn ( `Failed to resolve component: ${ name } ,${ extra } ` )
168+ }
169+ return returnValue
170+ }
0 commit comments