Skip to content

Commit a1797f8

Browse files
committed
fix(runtime-vapor): infer component name from registry
1 parent 325eb13 commit a1797f8

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

packages/runtime-vapor/src/warning.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,17 @@ export function formatComponentName(
178178
}
179179
}
180180

181-
// TODO registry
182-
// if (!name && instance && instance.parent) {
183-
// // try to infer the name based on reverse resolution
184-
// const inferFromRegistry = (registry: Record<string, any> | undefined) => {
185-
// for (const key in registry) {
186-
// if (registry[key] === Component) {
187-
// return key
188-
// }
189-
// }
190-
// }
191-
// name =
192-
// inferFromRegistry(
193-
// instance.components ||
194-
// (instance.parent.type as ComponentOptions).components,
195-
// ) || inferFromRegistry(instance.appContext.components)
196-
// }
181+
if (!name && instance && instance.parent) {
182+
// try to infer the name based on reverse resolution
183+
const inferFromRegistry = (registry: Record<string, any> | undefined) => {
184+
for (const key in registry) {
185+
if (registry[key] === Component) {
186+
return key
187+
}
188+
}
189+
}
190+
name = inferFromRegistry(instance.appContext.components)
191+
}
197192

198193
return name ? classify(name) : isRoot ? `App` : `Anonymous`
199194
}

0 commit comments

Comments
 (0)