Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 7a3a93b

Browse files
committed
fix(runtime-vapor): component self-reference
1 parent 114d501 commit 7a3a93b

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

packages/runtime-vapor/src/component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,10 @@ function getSlotsProxy(instance: ComponentInternalInstance): StaticSlots {
425425

426426
export function getComponentName(
427427
Component: Component,
428-
includeInferred = true,
429428
): string | false | undefined {
430429
return isFunction(Component)
431430
? Component.displayName || Component.name
432-
: Component.name || (includeInferred && Component.__name)
431+
: Component.name || Component.__name
433432
}
434433

435434
export function formatComponentName(

packages/runtime-vapor/src/helpers/resolveAssets.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ export const DIRECTIVES = 'directives'
88

99
export type AssetTypes = typeof COMPONENTS | typeof DIRECTIVES
1010

11-
export function resolveComponent(
12-
name: string,
13-
maybeSelfReference?: boolean,
14-
): string | Component {
15-
return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name
11+
export function resolveComponent(name: string): string | Component {
12+
return resolveAsset(COMPONENTS, name, true) || name
1613
}
1714

1815
export function resolveDirective(name: string): Directive | undefined {
@@ -27,30 +24,21 @@ function resolveAsset(
2724
type: typeof COMPONENTS,
2825
name: string,
2926
warnMissing?: boolean,
30-
maybeSelfReference?: boolean,
3127
): Component | undefined
3228
// overload 2: directives
3329
function resolveAsset(
3430
type: typeof DIRECTIVES,
3531
name: string,
3632
): Directive | undefined
3733
// implementation
38-
function resolveAsset(
39-
type: AssetTypes,
40-
name: string,
41-
warnMissing = true,
42-
maybeSelfReference = false,
43-
) {
34+
function resolveAsset(type: AssetTypes, name: string, warnMissing = true) {
4435
const instance = currentInstance
4536
if (instance) {
4637
const Component = instance.type
4738

4839
// explicit self name has highest priority
4940
if (type === COMPONENTS) {
50-
const selfName = getComponentName(
51-
Component,
52-
false /* do not include inferred name to avoid breaking existing code */,
53-
)
41+
const selfName = getComponentName(Component)
5442
if (
5543
selfName &&
5644
(selfName === name ||
@@ -65,11 +53,6 @@ function resolveAsset(
6553
// global registration
6654
resolve(instance.appContext[type], name)
6755

68-
if (!res && maybeSelfReference) {
69-
// fallback to implicit self-reference
70-
return Component
71-
}
72-
7356
if (__DEV__ && warnMissing && !res) {
7457
const extra =
7558
type === COMPONENTS

0 commit comments

Comments
 (0)