JSX maintains spaces that matter (fixes #30 and thus part of #73)

This commit is contained in:
Alex Rattray authored and James Long committed 2017-01-13 14:22:49 -05:00
1 parent b09a02084f
commit 2e1e6eece2
3 files changed
+17 -3

No files matched your search

+1 -1
View File
@@ -2034,7 +2034,7 @@ function printJSXElement(path, options, print) {
children.push(
beginBreak ? hardline : "",
child.value.replace(/^\s+|\s+$/g, ""),
child.value.replace(/^\s+|\s+$/g, endBreak ? "" : " "),
endBreak ? hardline : ""
);
} else if (/\n/.test(child.value)) {
@@ -73,13 +73,24 @@ const comp4 = (
<div
style={styles}
key=\"something\"
>Create wrapping parens and indent<strong>all the things</strong>.</div>
>Create wrapping parens and indent <strong>all the things</strong>.</div>
);
const comp5 = <div>Keep it on one line.</div>;
"
`;
exports[`test jsx-significant-space.js 1`] = `
"<span>
foo <span>bar</span>
</span>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<span>
foo <span>bar</span>
</span>;
"
`;
exports[`test jsx-split-attrs.js 1`] = `
"long_closed =
<BaseForm url=\"/auth/google\" method=\"GET\" colour=\"blue\" size=\"large\" submitLabel=\"Sign in with Google\"/>
@@ -168,7 +179,7 @@ const render4 = ({ styles }) => (
<div
style={styles}
key=\"something\"
>Create wrapping parens and indent<strong>all the things</strong>.</div>
>Create wrapping parens and indent <strong>all the things</strong>.</div>
);
const render5 = ({ styles }) => <div>Keep it on one line.</div>;
+3
View File
@@ -0,0 +1,3 @@
<span>
foo <span>bar</span>
</span>