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

React generates empty classnames in DOM if value is an empty string #30

Closed
vladshcherbin opened this issue Feb 23, 2019 · 4 comments
Closed

Comments

@vladshcherbin
Copy link
Contributor

Same as JedWatson/classnames#182

In react, if the value passed to className is an empty string, the html output will be <div class=""/>. In order to have a clean <div />, undefined should be passed.

Any idea how this can be solved? There is a PR in classnames, what do you think about this in classcat? :)

@jorgebucaran
Copy link
Owner

jorgebucaran commented Feb 23, 2019

@vladshcherbin Can <div class=""/> break an app?

Hyperapp's output is: <div class /> by the way.

@vladshcherbin
Copy link
Contributor Author

@jorgebucaran I don't think it can break an app.

Returning undefined just gives a clean html output without empty classes.

@jorgebucaran
Copy link
Owner

@vladshcherbin Return undefined and you may also end up with "undefined my-class" if you're concatenating Classcat's output with a string as someone already pointed out in the classNames PR.

React, Hyperapp should solve this, not Classcat. I want a clean DOM too, but changing Classcat to monkey-patch a JavaScript framework is worse.

I'll fix this in Hyperapp in jorgebucaran/hyperapp#754.

Thanks! 👋

@vladshcherbin
Copy link
Contributor Author

vladshcherbin commented Feb 24, 2019

@jorgebucaran sure, thanks :)

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

2 participants