@@ -72,6 +72,14 @@ export class Registry<T = any> {
7272 register ( type : string , component : ComponentRenderer < T > , meta ?: ComponentMeta ) {
7373 const fullType = meta ?. namespace ? `${ meta . namespace } :${ type } ` : type ;
7474
75+ // Warn if registering without namespace (deprecated pattern)
76+ if ( ! meta ?. namespace ) {
77+ console . warn (
78+ `Registering component "${ type } " without a namespace is deprecated. ` +
79+ `Please provide a namespace in the meta parameter.`
80+ ) ;
81+ }
82+
7583 if ( this . components . has ( fullType ) ) {
7684 // console.warn(`Component type "${fullType}" is already registered. Overwriting.`);
7785 }
@@ -84,7 +92,7 @@ export class Registry<T = any> {
8492
8593 // Also register without namespace for backward compatibility
8694 // This allows "button" to work even when registered as "ui:button"
87- if ( meta ?. namespace && ! this . components . has ( type ) ) {
95+ if ( meta ?. namespace ) {
8896 this . components . set ( type , {
8997 type : fullType , // Keep reference to namespaced type
9098 component,
@@ -113,16 +121,13 @@ export class Registry<T = any> {
113121 * registry.get('button', 'ui') // Tries 'ui:button' first, then 'button'
114122 */
115123 get ( type : string , namespace ?: string ) : ComponentRenderer < T > | undefined {
116- // Try namespaced lookup first if namespace provided
124+ // If namespace is explicitly provided, ONLY look in that namespace (no fallback)
117125 if ( namespace ) {
118126 const namespacedType = `${ namespace } :${ type } ` ;
119- const namespacedComponent = this . components . get ( namespacedType ) ;
120- if ( namespacedComponent ) {
121- return namespacedComponent . component ;
122- }
127+ return this . components . get ( namespacedType ) ?. component ;
123128 }
124129
125- // Fallback to direct type lookup
130+ // When no namespace provided, use backward compatibility lookup
126131 return this . components . get ( type ) ?. component ;
127132 }
128133
@@ -134,16 +139,13 @@ export class Registry<T = any> {
134139 * @returns Component configuration or undefined
135140 */
136141 getConfig ( type : string , namespace ?: string ) : ComponentConfig < T > | undefined {
137- // Try namespaced lookup first if namespace provided
142+ // If namespace is explicitly provided, ONLY look in that namespace (no fallback)
138143 if ( namespace ) {
139144 const namespacedType = `${ namespace } :${ type } ` ;
140- const namespacedConfig = this . components . get ( namespacedType ) ;
141- if ( namespacedConfig ) {
142- return namespacedConfig ;
143- }
145+ return this . components . get ( namespacedType ) ;
144146 }
145147
146- // Fallback to direct type lookup
148+ // When no namespace provided, use backward compatibility lookup
147149 return this . components . get ( type ) ;
148150 }
149151
@@ -155,12 +157,12 @@ export class Registry<T = any> {
155157 * @returns True if component is registered
156158 */
157159 has ( type : string , namespace ?: string ) : boolean {
160+ // If namespace is explicitly provided, ONLY look in that namespace (no fallback)
158161 if ( namespace ) {
159162 const namespacedType = `${ namespace } :${ type } ` ;
160- if ( this . components . has ( namespacedType ) ) {
161- return true ;
162- }
163+ return this . components . has ( namespacedType ) ;
163164 }
165+ // When no namespace provided, use backward compatibility lookup
164166 return this . components . has ( type ) ;
165167 }
166168
0 commit comments