-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
Coalesce adjacent strings into one text node #742
Conversation
This simplifies ReactMultiChild a little bit and will make it more practical to coalesce adjacent text strings.
👍 x10 |
Should make facebook#480 a little less painless. This brings us a lot closer to pretending we're in a world where text components don't exist at all; I think this is a lot nicer overall. With this, `<div>{['A', ' ', 'B']}</div>` turns into `<div>A B</div>` instead of `<div><span>A</span><span> </span><span>B</span></div>`. The only "weird" thing that I can see here is that `<div>x{flag && <a />}</div>` will toggle between rendering to `<div>x</div>` and `<div><span>x</span><a /></div>`.
If you use ReactChildren it won't coalesce later since it turns them into ReactTextComponent first. It would be nice to keep them as strings until they're mounted I guess. I'm not sure if it's worth while thrashing on these edge cases until we can get a consistent experience where we're never wrapping with spans and can clean up all the ReactTextComponent weirdness. |
I'll close this out but this is a great idea. If we can do it in multichild, we could get rid of spans completely. I think we can do it. That change would be easier to reason about since it just means that we never wrap things in weird ways. |
Agree, will look at doing that when I have time. |
This would be great also because the superfluous spans interfere badly with onMouseOver events: they "steal" these from their parent elements, which is very counterintuitive for the user. :( |
@thSoft Good catch. I still want to get rid of the spans completely and think that we can do it. |
The solution is to use onMouseEnter. This is why we had onMouseOver disabled before because it gives confusing effects in certain circumstances. |
But hovering the topmost element can be only done with onMouseOver/Out
|
@spicyj @sebmarkbage any plans on reviving this? Just curious. |
@spicyj updated the pull request. |
(What @facebook-github-bot? No I didn't.) @natew I'd like to fix this sometime but it hasn't been a priority. |
@natew @spicyj @facebook-github-bot Pure speculation: if there is some activity (any activity) on an old PR that predates @facebook-github-bot (perhaps a PR that doesn't have a review label), then github bot doesn't know about it and so it claims the PR was updated. |
Depends on #741.
Should make #480 a little less painless. This brings us a lot closer to pretending we're in a world where text components don't exist at all; I think this is a lot nicer overall.
With this,
<div>{['A', ' ', 'B']}</div>
turns into<div>A B</div>
instead of<div><span>A</span><span> </span><span>B</span></div>
.The only "weird" thing that I can see here is that
<div>x{flag && <a />}</div>
will toggle between rendering to<div>x</div>
and<div><span>x</span><a /></div>
.