-
Notifications
You must be signed in to change notification settings - Fork 104
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
CR and whitespaces break rendering #52
Comments
What kind of breakage are you seeing? Could you please provide an example? There are a plethora of unit tests that utilize line breaks and other types of whitespace and show appropriate behavior coming out - so I'm a little surprised to hear you're having trouble here. The component actually used to strip all whitespace in a manner similar to your suggestion - but simply doing that actually breaks things like |
I think we are not talking about the same. I am not referring the whitespaces between Check this for a live demo https://codesandbox.io/s/k5pkklv6ov?module=%2Fcomponents%2FApp.js |
After playing with your demo quite a bit, I noticed that you're dependent upon React 15, rather than React 16. This won't work - because Without it, you will also find that |
Ok I understand. Unfortunatelly we are forced to stick with React 15 atm. |
I don't currently have any plans to support an older version, unfortunately. As you correctly linked, the I would be open to having a secondary release, pinned to that version, if you guys (or others) were willing to help maintain it and help to keep feature parity. I'd also be open to refactoring the current version, if possible, to remove the dependency on We would need to figure out how to continue correctly supporting whitespace parsing and wrapperless rendering. I'm open to ideas here, and would be happy to participate in a PR. |
Hi Troy Using If you can provide me with insights about why you introduced |
There are two primary places the Fragment is needed. First is line 134, where we output the content without a wrapping The second spot is line 48, where we output the value of a This sucks. Because in our case, there is no element to render with Option 1 is, imho, patently incorrect - because you are actually changing the HTML being output, which could have unanticipated side-effects based on CSS rules or something. Option 3 felt elusive & over-complicated - so I didn't pursue it. Option 2, It's possible that some further exploration, here, would yield you some better fruit than I found - and if so, I'd love to see a different way to solve this icky problem. The other thing to watch for, if you do so, is the injection of multiple extra nodes. I don't recall exactly what I determined was causing them - but an earlier version of the code would render additional nodes of whitespace inside the component's rendered HTML. If this happens, there are several tests which should fail, showing an unexpected # of child nodes that doesn't match the assertions. |
The first issue is indeed not a big problem for us, since we don't mind a wrapper. Anyway would you mind providing me with a https://codesandbox.io/ that reproduces the second issue ( |
Playing with codesandbox a bit - I wonder if your code would just "work" with v1.1.6 of this package. That version is still pinned to React 15.6.1 and doesn't use |
Thanks for your suggestion. However we need the latest feature "ComponentsOnly" in order to avoid plain HTML in JSX. This would force us to change the v1.1.6 binaries as well. Therefore I rather fork the v1.3.2 branch and change the code to something like this:
|
cool - that seems like a reasonable interim solution. :) |
Hi Troy
In your readme you refer using the jsx prop as follows:
The carriage return as well as other whitespaces between every
<tag>
(including components) however will break your code and nothing will be rendered.I suggest removing all whitespaces between >< with a simple regex. E.g.:
.replace(/\>(\s|\n|\r|\t)*?\</g,"><")
If you want I can provide a pull request.
-Sandro
The text was updated successfully, but these errors were encountered: