Skip to content

Commit

Permalink
Better whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Sep 8, 2024
1 parent 432bcf4 commit 4ae8165
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions site/unity/vanillajsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ const jsxSymbol = t.callExpression(
[t.stringLiteral('jsx')],
);

const WHITESPACE = /[^\s]/;
const WHITESPACE = /^[ \t]*\n\s*$/;

export const babelPluginVanillaJSX: babel.PluginItem = {
visitor: {
JSXFragment: {
enter: (path) => {
path.node.children = path.node.children.filter(c => c.type !== 'JSXText' || c.value.match(WHITESPACE));
path.node.children = path.node.children.filter(c => c.type !== 'JSXText' || !c.value.match(WHITESPACE));

if (path.node.children.length === 1) {
const child = path.node.children[0]!;
Expand All @@ -39,7 +39,7 @@ export const babelPluginVanillaJSX: babel.PluginItem = {
},
JSXElement: {
enter: (path) => {
path.node.children = path.node.children.filter(c => c.type !== 'JSXText' || c.value.match(WHITESPACE));
path.node.children = path.node.children.filter(c => c.type !== 'JSXText' || !c.value.match(WHITESPACE));

let name;
const v = path.node.openingElement.name;
Expand Down

0 comments on commit 4ae8165

Please sign in to comment.