Skip to content

Svelte5 : Support for bracket notation in dynamic component rendering #13050

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

Closed
HitoshiroKyoka opened this issue Aug 28, 2024 · 2 comments
Closed

Comments

@HitoshiroKyoka
Copy link

Describe the problem

I would like to propose a feature to support bracket notation for rendering dynamic components. Currently, only dot notation is supported, but adding support for bracket notation would provide more flexibility.

example:
Svelte Lab

While dot notation is useful for static keys, bracket notation would provide more flexibility for dynamic keys and expressions.

Describe the proposed solution

Allow the use of bracket notation to access and render components from an object, similar to how it works with other JavaScript objects. For example:

<components[key]></components[key]>

Importance

would make my life easier

@brunnerh
Copy link
Member

I think this has been rejected.
Probably relevant PR:

@dummdidumm
Copy link
Member

Correct, we'll not add this capability. Using $derived in the script or @const in the template to prepare the component should be easy enough for this somewhat uncommon case.

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants