Fix a case where significant whitespace was dropped (#2270)

master
Karl O'Keeffe 2017-06-26 11:03:13 +01:00 committed by Christopher Chedeau
parent 400f34624f
commit fe7fb260a4
3 changed files with 31 additions and 0 deletions

View File

@ -3877,6 +3877,10 @@ function printJSXElement(path, options, print) {
children[i] === softline &&
children[i + 1] === "" &&
children[i + 2] === jsxWhitespace;
const isJSXWhitespaceFollowedBySoftline =
children[i] === jsxWhitespace &&
children[i + 1] === "" &&
children[i + 2] === softline;
const isEmptyFollowedByHardline =
children[i] === "" && children[i + 1] === hardline;
if (
@ -3885,6 +3889,8 @@ function printJSXElement(path, options, print) {
(isEmptyFollowedByHardline && containsText)
) {
children.splice(i, 2);
} else if (isJSXWhitespaceFollowedBySoftline) {
children.splice(i + 1, 2);
}
}

View File

@ -263,6 +263,14 @@ jsx_whitespace_after_tag =
{" "}
({variable})
</div>
x =
<div>
ENDS IN <div>
text text text text text text text text text text text
</div>{" "}
HRS
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Wrapping text
x = (
@ -598,4 +606,13 @@ jsx_whitespace_after_tag = (
</div>
);
x = (
<div>
ENDS IN <div>
text text text text text text text text text text text
</div>{" "}
HRS
</div>
);
`;

View File

@ -260,3 +260,11 @@ jsx_whitespace_after_tag =
{" "}
({variable})
</div>
x =
<div>
ENDS IN <div>
text text text text text text text text text text text
</div>{" "}
HRS
</div>