@@ -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,9 @@ 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+ // Note: If multiple namespaced components share the same short name,
96+ // the last registration wins for non-namespaced lookups
97+ if ( meta ?. namespace ) {
8898 this . components . set ( type , {
8999 type : fullType , // Keep reference to namespaced type
90100 component,
@@ -113,16 +123,13 @@ export class Registry<T = any> {
113123 * registry.get('button', 'ui') // Tries 'ui:button' first, then 'button'
114124 */
115125 get ( type : string , namespace ?: string ) : ComponentRenderer < T > | undefined {
116- // Try namespaced lookup first if namespace provided
126+ // If namespace is explicitly provided, ONLY look in that namespace (no fallback)
117127 if ( namespace ) {
118128 const namespacedType = `${ namespace } :${ type } ` ;
119- const namespacedComponent = this . components . get ( namespacedType ) ;
120- if ( namespacedComponent ) {
121- return namespacedComponent . component ;
122- }
129+ return this . components . get ( namespacedType ) ?. component ;
123130 }
124131
125- // Fallback to direct type lookup
132+ // When no namespace provided, use backward compatibility lookup
126133 return this . components . get ( type ) ?. component ;
127134 }
128135
@@ -134,16 +141,13 @@ export class Registry<T = any> {
134141 * @returns Component configuration or undefined
135142 */
136143 getConfig ( type : string , namespace ?: string ) : ComponentConfig < T > | undefined {
137- // Try namespaced lookup first if namespace provided
144+ // If namespace is explicitly provided, ONLY look in that namespace (no fallback)
138145 if ( namespace ) {
139146 const namespacedType = `${ namespace } :${ type } ` ;
140- const namespacedConfig = this . components . get ( namespacedType ) ;
141- if ( namespacedConfig ) {
142- return namespacedConfig ;
143- }
147+ return this . components . get ( namespacedType ) ;
144148 }
145149
146- // Fallback to direct type lookup
150+ // When no namespace provided, use backward compatibility lookup
147151 return this . components . get ( type ) ;
148152 }
149153
@@ -155,12 +159,12 @@ export class Registry<T = any> {
155159 * @returns True if component is registered
156160 */
157161 has ( type : string , namespace ?: string ) : boolean {
162+ // If namespace is explicitly provided, ONLY look in that namespace (no fallback)
158163 if ( namespace ) {
159164 const namespacedType = `${ namespace } :${ type } ` ;
160- if ( this . components . has ( namespacedType ) ) {
161- return true ;
162- }
165+ return this . components . has ( namespacedType ) ;
163166 }
167+ // When no namespace provided, use backward compatibility lookup
164168 return this . components . has ( type ) ;
165169 }
166170
0 commit comments