Properly handle \r\n in JSXText (#1170)

Fixes #1168
master
Christopher Chedeau 2017-04-09 16:37:54 -07:00 committed by GitHub
parent d1191adce6
commit 0e2bc09409
3 changed files with 15 additions and 1 deletions

View File

@ -2757,7 +2757,7 @@ function printJSXChildren(path, options, print, jsxWhitespace) {
if (/\S/.test(value)) {
// treat each line of text as its own entity
value.split(/(\n\s*)/).forEach(line => {
value.split(/(\r?\n\s*)/).forEach(line => {
const newlines = line.match(/\n/g);
if (newlines) {
children.push(hardline);

View File

@ -187,3 +187,14 @@ regression_extra_newline_2 = (
);
"
`;
exports[`windows.js 1`] = `
"<div>
Text
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<div>
Text
</div>;
"
`;

View File

@ -0,0 +1,3 @@
<div>
Text
</div>