Fix a case where significant whitespace was dropped (#2270)
parent
400f34624f
commit
fe7fb260a4
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
);
|
||||
|
||||
`;
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue