-
Notifications
You must be signed in to change notification settings - Fork 2
Fix Registry namespace lookup to enforce strict matching when namespace is explicit #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3f1fac4
f31af0d
080df1e
72093f9
1f4ab89
829cb97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -72,6 +72,14 @@ export class Registry<T = any> { | |||||||||||||
| register(type: string, component: ComponentRenderer<T>, meta?: ComponentMeta) { | ||||||||||||||
| const fullType = meta?.namespace ? `${meta.namespace}:${type}` : type; | ||||||||||||||
|
|
||||||||||||||
| // Warn if registering without namespace (deprecated pattern) | ||||||||||||||
| if (!meta?.namespace) { | ||||||||||||||
| console.warn( | ||||||||||||||
| `Registering component "${type}" without a namespace is deprecated. ` + | ||||||||||||||
| `Please provide a namespace in the meta parameter.` | ||||||||||||||
| ); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+75
to
+81
|
||||||||||||||
|
|
||||||||||||||
| if (this.components.has(fullType)) { | ||||||||||||||
| // console.warn(`Component type "${fullType}" is already registered. Overwriting.`); | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -84,7 +92,9 @@ export class Registry<T = any> { | |||||||||||||
|
|
||||||||||||||
| // Also register without namespace for backward compatibility | ||||||||||||||
| // This allows "button" to work even when registered as "ui:button" | ||||||||||||||
| if (meta?.namespace && !this.components.has(type)) { | ||||||||||||||
| // Note: If multiple namespaced components share the same short name, | ||||||||||||||
| // the last registration wins for non-namespaced lookups | ||||||||||||||
| if (meta?.namespace) { | ||||||||||||||
|
Comment on lines
+95
to
+97
|
||||||||||||||
| // Note: If multiple namespaced components share the same short name, | |
| // the last registration wins for non-namespaced lookups | |
| if (meta?.namespace) { | |
| // Preserve existing non-namespaced registrations for backward compatibility. | |
| // Only create the short-name alias if it does not already exist. | |
| if (meta?.namespace && !this.components.has(type)) { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,4 +32,7 @@ export default defineConfig({ | |
| ], | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,4 +47,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,4 +47,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,4 +45,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,4 +46,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,4 +41,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,4 +43,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,4 +36,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,4 +47,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,4 +36,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,4 +45,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,4 +47,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,4 +43,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,4 +45,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,4 +37,7 @@ export default defineConfig({ | |
| }, | ||
| }, | ||
| }, | ||
| test: { | ||
| passWithNoTests: true, | ||
| }, | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deprecation warning triggers for both
undefinednamespace and empty string namespace. Since empty string is explicitly handled as "no namespace" (line 73), it may be intentional to allow empty string without warning. Consider whether the warning should check for explicit empty string and handle it differently, or if empty strings should also be deprecated. The current behavior may produce unexpected warnings for users who explicitly pass{ namespace: '' }.