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

Created on 19 Jul 2019  路  1Comment  路  Source: facebook/react

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:

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
Server Rendering Bug

Most helpful comment

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.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings