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

Fixes #1168
This commit is contained in:
Christopher Chedeau authored and GitHub committed 2017-04-09 16:37:54 -07:00
1 parent d1191adce6
commit 0e2bc09409
3 files changed
+15 -1

No files matched your search

+1 -1
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);
@@ -187,3 +187,14 @@ regression_extra_newline_2 = (
);
"
`;
exports[`windows.js 1`] = `
"<div>
Text
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<div>
Text
</div>;
"
`;
+3
View File
@@ -0,0 +1,3 @@
<div>
Text
</div>