Skip to content

For JSX text, construct a single literal node "foo bar" instead of "foo" + " " + "bar" #10782

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

Merged
6 commits merged into from
Jan 5, 2017

Conversation

ghost
Copy link

@ghost ghost commented Sep 8, 2016

No description provided.

@DanielRosenwasser
Copy link
Member

Is there an issue tracking this?

@ghost
Copy link
Author

ghost commented Sep 8, 2016

This is not a bug. The output was just unnecessarily complicated.

@RyanCavanaugh
Copy link
Member

FWIW Babel used to emit the "foo" + " " + "bar" but now emits "foo bar" as well

@rbuckton
Copy link
Contributor

rbuckton commented Sep 8, 2016

@Andy-MS there are some failing tests in this PR.

// when it emits the literal. We do, however, need to decode JSX entities.
parts.push(createLiteral(decodeEntities(part)));
const part = decodeEntities(text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1));
acc = acc === undefined ? part : acc + " " + part;
Copy link
Member

@DanielRosenwasser DanielRosenwasser Sep 8, 2016

Choose a reason for hiding this comment

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

If you write

<div>

    hello\

world
</div>

What is the output?

Copy link
Author

Choose a reason for hiding this comment

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

It will be properly escaped: "hello\\ world".

@RyanCavanaugh
Copy link
Member

CI's failing again

@ghost ghost merged commit 91af4ae into master Jan 5, 2017
@ghost ghost deleted the react_whitespace branch January 5, 2017 21:55
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants