Skip to content

Commit

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

const WHITESPACE = /[^\s]/;

export const babelPluginVanillaJSX: babel.PluginItem = {
visitor: {
JSXFragment: {
enter: (path) => {
path.node.children = path.node.children.filter(c => c.type !== 'JSXText' || c.value.match(/[^\s]/));
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 @@ -37,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(/[^\s]/));
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 1407875

Please sign in to comment.