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

Quote name of attribute to nested components #1555

Merged
merged 2 commits into from
Jun 29, 2018

Conversation

fjorgemota
Copy link
Contributor

@fjorgemota fjorgemota commented Jun 22, 2018

This fixes #887 by quoting name of attributes if those are invalid JS identifiers when passing data to nested components, so something like this would compile and run successfully.

Please note that this does not add support for acessing these attributes directly on the component code, but only adds support for passing that data to the nested component. I think a valid idea here is to let the user use a computed property on the nested component returning the whole state (like state, maybe?) to access the data on template tags using { state["b-c"] }, for example.

I'll add tests tonight, by the way, so this is still a WIP. But feel free to test and comment about the idea. =)

This fixes sveltejs#887 by quoting name of attributes if those are invalid JS identifiers when passing data to nested components.
@fjorgemota fjorgemota changed the title Quote name of attribute to nested components (WIP) [WIP] Quote name of attribute to nested components Jun 22, 2018
@fjorgemota
Copy link
Contributor Author

Ok, I added a few tests of what I was thinking about the support to invalid JS identifiers as attributes to nested components.

Please note that I did not add support for the usage of invalid JS attributes on any other place than bind: and attributes passed to nested components. So, for example, we cannot use {b-c} or bind:x='b-c', for example, which for me is a bit confusing, but I do not see it as a problem when considering ONLY the original issue.

I'll remove the WIP flag (as this PR already has tests included), but really feel free to comment on the "solution" to the issue. Thanks for the great project, by the way. :)

@fjorgemota fjorgemota changed the title [WIP] Quote name of attribute to nested components Quote name of attribute to nested components Jun 25, 2018
@Rich-Harris Rich-Harris merged commit 5c6e7e8 into sveltejs:master Jun 29, 2018
@Rich-Harris
Copy link
Member

thank you! released 2.9.0 with the fix

@fjorgemota
Copy link
Contributor Author

Thank you! :D

@fjorgemota fjorgemota deleted the patch-1 branch June 30, 2018 17:51
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

Successfully merging this pull request may close these issues.

Component arguments that are not valid JS identifiers
2 participants