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

JSX: Improved spread operator in tag attributes #2159

Merged
merged 2 commits into from Jan 6, 2020

Conversation

0xc14m1z
Copy link
Contributor

@0xc14m1z 0xc14m1z commented Jan 5, 2020

This is a small tweak of tag regexes that allow spaces within the brackets of spread operator.

Copy link
Member

@RunDevelopment RunDevelopment left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
Just one nit: There can be any number of spaces between ... and the variable.

Also, the spread expression can be any valid JS expression or is it really just [a-z_$][\w$]*(?:\.[a-z_$][\w$]*)* ? So e.g. is <div {...foo.bar('baz')}></div> valid?

@0xc14m1z
Copy link
Contributor Author

0xc14m1z commented Jan 6, 2020

First of all, thanks for considering my PR.
Then, I followed your suggestion and allowed for any number of spaces between the dots and the expression.

Regarding your question... no. It doesn't take account for javascript expression after the .... This PR is intended as a tweak for the spaces.

Considered the README though, where small and focused PR are preferred to multi-feature ones, I think that making expressions to work should be another PR. I tried here and it doesn't work.

@RunDevelopment RunDevelopment merged commit fd857e7 into PrismJS:master Jan 6, 2020
@RunDevelopment
Copy link
Member

Thank you for contributing!

And thanks for your answer. I just wanted to know. Making a pattern which allows any JS expression is extremely tricky, so I'll do that myself :)

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

Successfully merging this pull request may close these issues.

None yet

2 participants