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

Not working with extra spaces in styleName #17

Open
gauravkumar37 opened this issue Sep 28, 2020 · 1 comment
Open

Not working with extra spaces in styleName #17

gauravkumar37 opened this issue Sep 28, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@gauravkumar37
Copy link

When styleName contains extra spaces, the library doesn't work. In fact the entire output of the component disappears rather than giving a warning.
Extra spaces can be present as a result of conditional styles.
For example, when isLoggedIn is false, the resulting string becomes class1 (with an extra space at the end).

<div styleName={'class1 ' + (isLoggedIn ? 'green' : '')}>Hi</div>

Of course, this can very easily be worked around by moving the space from class1 to isLoggedIn.

I believe empty strings should be filtered out after splitting on space in

const stringValueReplacement = styleNameAttr.value.value
.split(" ")
.map(val => t.stringLiteral(val));

@bohdanbirdie
Copy link
Owner

Hi!
Yep, good catch
Would you like to create a PR?
I will be glad to merge it ;)

@bohdanbirdie bohdanbirdie added the bug Something isn't working label Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants