@@ -24,7 +24,7 @@ import { Slots, initSlots, InternalSlots } from './componentSlots'
24
24
import { warn } from './warning'
25
25
import { ErrorCodes , callWithErrorHandling } from './errorHandling'
26
26
import { AppContext , createAppContext , AppConfig } from './apiCreateApp'
27
- import { Directive , validateDirectiveName } from './directives'
27
+ import { validateDirectiveName } from './directives'
28
28
import { applyOptions , ComponentOptions } from './componentOptions'
29
29
import {
30
30
EmitsOptions ,
@@ -223,17 +223,6 @@ export interface ComponentInternalInstance {
223
223
*/
224
224
renderCache : ( Function | VNode ) [ ]
225
225
226
- /**
227
- * Asset hashes that prototypally inherits app-level asset hashes for fast
228
- * resolution
229
- * @internal
230
- */
231
- components : Record < string , Component >
232
- /**
233
- * @internal
234
- */
235
- directives : Record < string , Directive >
236
-
237
226
// the rest are only for stateful components ---------------------------------
238
227
239
228
// main proxy that serves as the public instance (`this`)
@@ -354,15 +343,17 @@ export function createComponentInstance(
354
343
parent : ComponentInternalInstance | null ,
355
344
suspense : SuspenseBoundary | null
356
345
) {
346
+ const type = vnode . type as Component
357
347
// inherit parent app context - or - if root, adopt from root vnode
358
348
const appContext =
359
349
( parent ? parent . appContext : vnode . appContext ) || emptyAppContext
350
+
360
351
const instance : ComponentInternalInstance = {
361
352
uid : uid ++ ,
362
353
vnode,
354
+ type,
363
355
parent,
364
356
appContext,
365
- type : vnode . type as Component ,
366
357
root : null ! , // to be immediately set
367
358
next : null ,
368
359
subTree : null ! , // will be set synchronously right after creation
@@ -385,10 +376,6 @@ export function createComponentInstance(
385
376
setupState : EMPTY_OBJ ,
386
377
setupContext : null ,
387
378
388
- // per-instance asset storage (mutable during options resolution)
389
- components : Object . create ( appContext . components ) ,
390
- directives : Object . create ( appContext . directives ) ,
391
-
392
379
// suspense related
393
380
suspense,
394
381
asyncDep : null ,
@@ -727,14 +714,18 @@ export function formatComponentName(
727
714
}
728
715
729
716
if ( ! name && instance && instance . parent ) {
730
- // try to infer the name based on local resolution
731
- const registry = instance . parent . components
732
- for ( const key in registry ) {
733
- if ( registry [ key ] === Component ) {
734
- name = key
735
- break
717
+ // try to infer the name based on reverse resolution
718
+ const inferFromRegistry = ( registry : Record < string , any > | undefined ) => {
719
+ for ( const key in registry ) {
720
+ if ( registry [ key ] === Component ) {
721
+ return key
722
+ }
736
723
}
737
724
}
725
+ name =
726
+ inferFromRegistry (
727
+ ( instance . parent . type as ComponentOptions ) . components
728
+ ) || inferFromRegistry ( instance . appContext . components )
738
729
}
739
730
740
731
return name ? classify ( name ) : isRoot ? `App` : `Anonymous`
0 commit comments