Fix self-closing jsx element codegen

We were never emitting self-closing jsx elements because children were never 
null, we now set children to null if they were empty in the AST.
This commit is contained in:
Joe Savona
2023-03-17 16:18:11 -07:00
parent a7ac20973f
commit ff8868e8d1
25 changed files with 26 additions and 26 deletions
+1 -1
View File
@@ -1439,7 +1439,7 @@ function lowerExpression(
kind: "JsxExpression",
tag,
props,
children,
children: children.length === 0 ? null : children,
loc: exprLoc,
};
}
@@ -38,7 +38,7 @@ function Component(props) {
}
let t0;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t0 = <div a={a} b={b}></div>;
t0 = <div a={a} b={b} />;
$[2] = t0;
} else {
t0 = $[2];
@@ -59,7 +59,7 @@ function component(a, b) {
const c_7 = $[7] !== x;
let t3;
if (c_7) {
t3 = <Foo x={x}></Foo>;
t3 = <Foo x={x} />;
$[7] = x;
$[8] = t3;
} else {
@@ -50,7 +50,7 @@ function component(t27) {
const c_5 = $[5] !== hide;
let t2;
if (c_4 || c_5) {
t2 = <Foo poke={poke} hide={hide}></Foo>;
t2 = <Foo poke={poke} hide={hide} />;
$[4] = poke;
$[5] = hide;
$[6] = t2;
@@ -29,7 +29,7 @@ function component() {
const c_2 = $[2] !== handler;
let t1;
if (c_2) {
t1 = <Foo handler={handler}></Foo>;
t1 = <Foo handler={handler} />;
$[2] = handler;
$[3] = t1;
} else {
@@ -59,7 +59,7 @@ function ComponentA(props) {
const c_4 = $[4] !== b;
let t0;
if (c_3 || c_4) {
t0 = <Foo a={a} b={b}></Foo>;
t0 = <Foo a={a} b={b} />;
$[3] = a;
$[4] = b;
$[5] = t0;
@@ -94,7 +94,7 @@ function ComponentB(props) {
const c_4 = $[4] !== b;
let t0;
if (c_3 || c_4) {
t0 = <Foo a={a} b={b}></Foo>;
t0 = <Foo a={a} b={b} />;
$[3] = a;
$[4] = b;
$[5] = t0;
@@ -37,7 +37,7 @@ function Component(props) {
}
let t0;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t0 = <div a={a} b={b}></div>;
t0 = <div a={a} b={b} />;
$[2] = t0;
} else {
t0 = $[2];
@@ -30,7 +30,7 @@ function component() {
const c_3 = $[3] !== x;
let t1;
if (c_2 || c_3) {
t1 = <input onChange={handler} value={x}></input>;
t1 = <input onChange={handler} value={x} />;
$[2] = handler;
$[3] = x;
$[4] = t1;
@@ -39,7 +39,7 @@ function Component(props) {
const c_5 = $[5] !== d;
let t0;
if (c_4 || c_5) {
t0 = <div b={b} d={d}></div>;
t0 = <div b={b} d={d} />;
$[4] = b;
$[5] = d;
$[6] = t0;
@@ -82,7 +82,7 @@ function Component(props) {
const c_6 = $[6] !== b;
let t0;
if (c_5 || c_6) {
t0 = <Foo a={a} b={b}></Foo>;
t0 = <Foo a={a} b={b} />;
$[5] = a;
$[6] = b;
$[7] = t0;
@@ -63,7 +63,7 @@ function Component(props) {
const c_5 = $[5] !== b;
let t2;
if (c_4 || c_5) {
t2 = <Foo a={a} b={b}></Foo>;
t2 = <Foo a={a} b={b} />;
$[4] = a;
$[5] = b;
$[6] = t2;
@@ -70,7 +70,7 @@ function Component(props) {
const c_6 = $[6] !== b;
let t0;
if (c_5 || c_6) {
t0 = <Foo a={a} b={b}></Foo>;
t0 = <Foo a={a} b={b} />;
$[5] = a;
$[6] = b;
$[7] = t0;
@@ -58,7 +58,7 @@ function Component(props) {
const c_5 = $[5] !== b;
let t0;
if (c_4 || c_5) {
t0 = <Foo a={a} b={b}></Foo>;
t0 = <Foo a={a} b={b} />;
$[4] = a;
$[5] = b;
$[6] = t0;
@@ -19,7 +19,7 @@ function Component(props) {
const $ = React.unstable_useMemoCache(2);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = <Foo.Bar.Baz></Foo.Bar.Baz>;
t0 = <Foo.Bar.Baz />;
$[0] = t0;
} else {
t0 = $[0];
@@ -30,7 +30,7 @@ function Component(props) {
const c_3 = $[3] !== t1;
let t2;
if (c_2 || c_3) {
t2 = <Component {...props} {...t1}></Component>;
t2 = <Component {...props} {...t1} />;
$[2] = props;
$[3] = t1;
$[4] = t2;
@@ -26,7 +26,7 @@ function Component(props) {
const y = [];
x.y = y;
child = <Component data={y}></Component>;
child = <Component data={y} />;
x.y.push(props.p0);
$[0] = props.p0;
$[1] = x;
@@ -51,7 +51,7 @@ function Component(props) {
const c_4 = $[4] !== y;
let t1;
if (c_3 || c_4) {
t1 = <Component x={x} y={y}></Component>;
t1 = <Component x={x} y={y} />;
$[3] = x;
$[4] = y;
$[5] = t1;
@@ -52,7 +52,7 @@ function Component(props) {
const c_6 = $[6] !== y;
let t1;
if (c_5 || c_6) {
t1 = <Component x={x} y={y}></Component>;
t1 = <Component x={x} y={y} />;
$[5] = x;
$[6] = y;
$[7] = t1;
@@ -44,7 +44,7 @@ function Component(props) {
}
let t0;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t0 = <div a={a} b={b}></div>;
t0 = <div a={a} b={b} />;
$[2] = t0;
} else {
t0 = $[2];
@@ -38,7 +38,7 @@ function Component(props) {
}
let t0;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t0 = <div a={a} b={b}></div>;
t0 = <div a={a} b={b} />;
$[2] = t0;
} else {
t0 = $[2];
@@ -71,7 +71,7 @@ function Component(props) {
const c_4 = $[4] !== x;
let t1;
if (c_4) {
t1 = <Component data={x}></Component>;
t1 = <Component data={x} />;
$[4] = x;
$[5] = t1;
} else {
@@ -52,7 +52,7 @@ function Component(props) {
const c_3 = $[3] !== x;
let t0;
if (c_3) {
t0 = <Component data={x}></Component>;
t0 = <Component data={x} />;
$[3] = x;
$[4] = t0;
} else {
@@ -32,7 +32,7 @@ function component() {
const c_3 = $[3] !== increment;
let t1;
if (c_3) {
t1 = <Foo onClick={increment}></Foo>;
t1 = <Foo onClick={increment} />;
$[3] = increment;
$[4] = t1;
} else {
@@ -27,7 +27,7 @@ function component(a) {
const c_2 = $[2] !== x;
let t1;
if (c_2) {
t1 = <Foo x={x}></Foo>;
t1 = <Foo x={x} />;
$[2] = x;
$[3] = t1;
} else {
@@ -34,7 +34,7 @@ function Component(props) {
t0 = $[1];
}
const onChange = t0;
return <form>{<input onChange={onChange} value={name}></input>}</form>;
return <form>{<input onChange={onChange} value={name} />}</form>;
}
```