Skip to content

Commit

Permalink
fix(runtime-vapor): infer component name from registry
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jun 16, 2024
1 parent 325eb13 commit a1797f8
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions packages/runtime-vapor/src/warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,17 @@ export function formatComponentName(
}
}

// TODO registry
// if (!name && instance && instance.parent) {
// // try to infer the name based on reverse resolution
// const inferFromRegistry = (registry: Record<string, any> | undefined) => {
// for (const key in registry) {
// if (registry[key] === Component) {
// return key
// }
// }
// }
// name =
// inferFromRegistry(
// instance.components ||
// (instance.parent.type as ComponentOptions).components,
// ) || inferFromRegistry(instance.appContext.components)
// }
if (!name && instance && instance.parent) {
// try to infer the name based on reverse resolution
const inferFromRegistry = (registry: Record<string, any> | undefined) => {
for (const key in registry) {
if (registry[key] === Component) {
return key
}
}
}
name = inferFromRegistry(instance.appContext.components)
}

return name ? classify(name) : isRoot ? `App` : `Anonymous`
}
Expand Down

0 comments on commit a1797f8

Please sign in to comment.