ssr icon indicating copy to clipboard operation
ssr copied to clipboard

html-minifier causes React to throw reconciliation errors.

Open cbilotta opened this issue 9 years ago • 6 comments

The HTML minifier is not aligned with React rendering because it does things such as :

  • Stripping whitespaces inside of elements, this is very good but if you don't manually strip the string yourself React will complain since it will render it with the whitespaces on the client.
  • Deleting the ; at the end on inline style-tags. Unfortunately, this is React's default behavior to put a ; at the end of inline style tags even if it's not necessary so it causes conflics.

I don't know about other differences between the react rendering and the html-minifier, but we should search for them and make sure it doesn't cause problems in the future.

I guess, the html-minifier should simply not do anything except removing whitespaces between tags.

cbilotta avatar Apr 06 '17 11:04 cbilotta

Indeed, concerning the inlined styles, this should be treated here: https://github.com/facebook/react/blob/master/src/renderers/dom/shared/CSSPropertyOperations.js#L172

PEM-- avatar Apr 06 '17 12:04 PEM--

Should I put an issue on React or html-minifier ? Not sure which one will listen 😄

cbilotta avatar Apr 06 '17 13:04 cbilotta

I'm doing it right now. I'll reference our issue in FB's repo.

PEM-- avatar Apr 06 '17 13:04 PEM--

I've also referenced this issue on html-minifier as it should not alter inline styles when minifyCss is set to false.

PEM-- avatar Apr 06 '17 13:04 PEM--

I will make a commit where I comment the code responsible of making the minification happen for now. So we can keep on iterating the demo without having bugs.

cbilotta avatar Apr 06 '17 17:04 cbilotta

From my understanding, this has been fixed in both react and html-minifier. I will do what is necessary to re-enable html minification in the develop branch and make sure it doesn't cause bugs anymore.

cbilotta avatar Oct 10 '17 09:10 cbilotta