-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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 16 fails to rehydrate noscripts #10993
Comments
As an additional detail I noticed some of the attributes are rendered using the DOM property name instead of HTML attribute name.
React 15: This is incorrect both client and server side in React 16.0.0 Reported here as I think this seems very related to this particular bug. |
I don't think it is technically incorrect because HTML is case-insensitive. Although it doesn't hurt to lowercase them and we can do that. |
Ah yes, I had already forgotten that. Used XHTML for so many years that it stuck :) Then the only reason to do that would be for full backwards compatibility with 15, unless XHTML compatibility is considered a thing in 2017. |
Just a note: the usual caveats about downcasing with SVG apply (SVG has case-sensitive attributes). For instance, From recent PRs (#11033), it looks like similar issues are on @gaearon's mind; posting here just for posterity, as naively "downcasing everything" is not sound. |
Regarding case sensitivity, there is an existing issue: #10863. |
OK, what seems to be happening is that assigning |
I have a fix in #11157. |
Thanks very much @gaearon! |
Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
As of React 16,
<noscript dangerouslySetInnerHTML={...} />
s are not properly rehydrated. Equivalent code works in React 15.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/ebsrpraL/).
Consider the following server-side code:
This code works fine in Reacts 15 and 16 alike; the outputs are similar:
Now, consider the following application (jsbin):
In React 16, this displays the following in the console:
If you swap the comment blocks in the HTML so that React 15 is used, the code works just fine: there are no warnings. (This is true regardless of whether you change the contents of
div#target
from the React 16 output to the React 15 output.)The error message confuses me; it states that the server output is
but this is not consistent with the output of the server-side code (neither the "Contents" nor the final markup emitted has HTML entities).
Please note that this is important because it breaks the only known workaround to #1252.
I believe that this may be specific to
noscript
s, because if one replaces all occurrences ofnoscript
withdiv
then the example works fine in React 16.What is the expected behavior?
Rendering a component with
renderToString
and then rehydrating that component verbatim should not yield an error.Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Regression from 15 to 16. Tested in Chrome v61.
The text was updated successfully, but these errors were encountered: