Skip to content
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

Binding spread attributes #5137

Open
RiseNet-Web opened this issue Jul 13, 2020 · 6 comments
Open

Binding spread attributes #5137

RiseNet-Web opened this issue Jul 13, 2020 · 6 comments

Comments

@RiseNet-Web
Copy link

Is your feature request related to a problem? Please describe.
I try, to create some component, and i would like use spread attributes. However we can't bind this kind of attributes. Tha's why I think about a solution

Describe the solution you'd like
bind spread like bind:{...attributes}

Describe alternatives you've considered
I don't an other alternatives

How important is this feature to you?
I think it's important, but it's not like a principal feature.

Additional context
Add any other context or screenshots about the feature request here.

@Florian-Schoenherr
Copy link

I have no idea how svelte does stuff internally, but some suggestions:

  • bind:props={...props} would make props reserved
  • bind:{...props} doesn't look like correct syntax
  • maybe bind:$$props={...props}?

Basically, bind:???={...props}

@HamishWHC
Copy link

I don't think props being reserved should be a major issue, given that this is already reserved.
Another option may be {...bind:props}, based on the existing spread syntax? I don't think : is a valid character for variable names, so this shouldn't break anything.

@Florian-Schoenherr
Copy link

Both great, we just need someone to see this who knows more about internals / which one is easier to implement.
Or a hero who implements it 😄

@HamishWHC
Copy link

Took a poke around, and it seems this is where spread parsing occurs: https://github.com/sveltejs/svelte/blob/master/src/compiler/parse/state/tag.ts#L310 Given that {...bind:props} is just adding bind: after the spread operator, this part should be simple. Now to figure out compilation.

@stale
Copy link

stale bot commented Jun 26, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@sxxov
Copy link

sxxov commented Aug 1, 2021

I've written an RFC at sveltejs/rfcs#57 in an attempt to propose a solution for this. Anyone one looking at this problem should feel free to chime in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants