Skip to content

Adjacent text nodes in SSR should have comments between them despite components - #11109

Merged
gaearon merged 4 commits into
react:masterfrom
gaearon:fix-ssr-text-node
Oct 5, 2017
Merged

Adjacent text nodes in SSR should have comments between them despite components#11109
gaearon merged 4 commits into
react:masterfrom
gaearon:fix-ssr-text-node

Conversation

@gaearon

@gaearon gaearon commented Oct 5, 2017

Copy link
Copy Markdown
Contributor

This fixes #10598.
See individual commits and test cases I added.

This ensures we don't reset it when we exit components that return strings.
This fixes the {'a'}</div>{'b'} case and prevents an unnecessary comment before 'b'.
@reactjs-bot

Copy link
Copy Markdown

Deploy preview ready!

Built with commit cd2df6c

https://deploy-preview-11109--reactjs.netlify.com

@gaearon gaearon mentioned this pull request Oct 5, 2017
19 tasks
@gaearon
gaearon requested a review from nhunzaker October 5, 2017 13:45

@sophiebits sophiebits left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. thank you!

@gaearon
gaearon merged commit 32ec797 into react:master Oct 5, 2017
@gaearon
gaearon deleted the fix-ssr-text-node branch October 6, 2017 20:48
frame.debugElementStack = [];
}
this.stack.push(frame);
this.previousWasTextNode = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is this unnecessary now? Seems like the fix was the second commit, not this, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember it right I tried commenting both places out separately after adding the tests, and both were necessary. This one resets when we're entering a tag, and another resets when we're leaving a tag.

mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
…components (react#11109)

* Add a failing test for text nodes within components

* Reset the text node flag only when emitting tags

This ensures we don't reset it when we exit components that return strings.

* Add a failing test for a more complex tree

* Also reset text flag when emitting a footer

This fixes the {'a'}</div>{'b'} case and prevents an unnecessary comment before 'b'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Returning plain string from component renders collapsed text nodes on server

5 participants