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

Avoid adding ';' in inlined styles when unnecessary #9353

Closed
PEM-- opened this issue Apr 6, 2017 · 5 comments
Closed

Avoid adding ';' in inlined styles when unnecessary #9353

PEM-- opened this issue Apr 6, 2017 · 5 comments

Comments

@PEM--
Copy link

PEM-- commented Apr 6, 2017

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

Sounds like a feature but this is causing problem when server side generated HTML payload are pass through html-minifier.

What is the current behavior?

As stated in the serialization function: https://github.com/facebook/react/blob/master/src/renderers/dom/shared/CSSPropertyOperations.js#L172, all properties are ended with a ;.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/84v837e9/).

N/A

What is the expected behavior?

All properties should be ended with a ; except the last one.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

N/A

Referenced issue: ssrwpo/ssr#45

@syranide
Copy link
Contributor

syranide commented Apr 6, 2017

Sounds like a feature but this is causing problem when server side generated HTML payload are pass through html-minifier.

What's the problem exactly?

@PEM--
Copy link
Author

PEM-- commented Apr 6, 2017

When I minify HTML rendered with React, last ; in inline styles are stripped. When the client performs the reconciliation, React sees a difference and warn about it.

Removing the last ; in inline styles would prevent this and spare some bandwidth as more and more users are relying on solution using style injection.

@syranide
Copy link
Contributor

syranide commented Apr 6, 2017

When I minify HTML rendered with React, last ; in inline styles are stripped. When the client performs the reconciliation, React sees a difference and warn about it.

That's not how reconciliation works at the moment, it computes a hash which the client checks. HOWEVER the error message will highlight the semicolon as the possible culprit because it doesn't know for sure what the server generated and tries to make a best guess. If that is how it worked you wouldn't be allowed to run the minifier over the code at all, because any change would trip React.

Tl;dr; the semicolon is not actually the problem.

@PEM--
Copy link
Author

PEM-- commented Apr 6, 2017

So removing the last ; would at least spare bandwidth.

@aweary
Copy link
Contributor

aweary commented Sep 20, 2017

This was fixed in #9550 🎉

@aweary aweary closed this as completed Sep 20, 2017
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

3 participants