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

Bug: React DOM Server is mutating CSS variable names #16160

Closed
rdhaliwal opened this issue Jul 18, 2019 · 1 comment · Fixed by #16167
Closed

Bug: React DOM Server is mutating CSS variable names #16160

rdhaliwal opened this issue Jul 18, 2019 · 1 comment · Fixed by #16167

Comments

@rdhaliwal
Copy link

rdhaliwal commented Jul 18, 2019

Do you want to request a feature or report a bug?

Bug

Current Behaviour

  • ReactDOMServer.renderToString is mutating CSS Variable names that are inlined and in the --camelCase format into --kebab-case

Expected Behaviour

  • ReactDOMServer.renderToString does not mutate the CSS Variable name, and keeps it in --camelCase format

Demo

Versions:

  • Issue appears in react@16.8.6 & react-dom@16.8.6
  • Issue appears in react@16.0.0 & react-dom@16.0.0
  • (That's all I've tested so far)

Other notes:

  • It's worth noting that ReactDOM.render is preserving the CSS Variable name and not mutating it. It only seems to only be an issue with ReactDOMServer.renderToString
@bedakb
Copy link
Contributor

bedakb commented Jul 19, 2019

I'd like to work on this one.

I think problem is the createMarkupForStyles function (react-dom/server/ReactPartialRenderer.js), because It runs hyphenateStyleName on custom css property so that's why CSS variable casing is mutated.

I assume solution should looks like this:

serialized += delimiter + (isCustomProperty ? styleName : processStyleName(styleName)) + ':';

Maybe It would be better to perform check inside processStyleName function so styleName is cached as well.

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

Successfully merging a pull request may close this issue.

3 participants