diff options
author | 2021-08-17 04:09:02 -0700 | |
---|---|---|
committer | 2021-08-17 04:09:02 -0700 | |
commit | ca6514c77ca665cff0d3bfe00077d421af10af2e (patch) | |
tree | 541b8e059a79d63a9fcc8c0c4cac928249ee734f /src | |
parent | d27a599ec2ce734f9ad5490dcfac5e3b97cef30f (diff) | |
download | bun-ca6514c77ca665cff0d3bfe00077d421af10af2e.tar.gz bun-ca6514c77ca665cff0d3bfe00077d421af10af2e.tar.zst bun-ca6514c77ca665cff0d3bfe00077d421af10af2e.zip |
Fix JSX runtime when children are 0
Former-commit-id: 094913a99f22888b97696aabe12fc1a5452788d6
Diffstat (limited to 'src')
-rw-r--r-- | src/js_parser/js_parser.zig | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig index a06277b5e..4d6189cbc 100644 --- a/src/js_parser/js_parser.zig +++ b/src/js_parser/js_parser.zig @@ -10545,18 +10545,20 @@ pub fn NewParser( // ...props, // children: [] // } - for (e_.children[0..children_count]) |child, i| { - e_.children[i] = p.visitExpr(child); - } - const children_key = Expr{ .data = jsxChildrenKeyData, .loc = expr.loc }; - props.append(G.Property{ - .key = children_key, - .value = p.e(E.Array{ - .items = e_.children, - .is_single_line = e_.children.len < 2, - }, expr.loc), - }) catch unreachable; + if (children_count > 0) { + for (e_.children[0..children_count]) |child, i| { + e_.children[i] = p.visitExpr(child); + } + const children_key = Expr{ .data = jsxChildrenKeyData, .loc = expr.loc }; + props.append(G.Property{ + .key = children_key, + .value = p.e(E.Array{ + .items = e_.children, + .is_single_line = e_.children.len < 2, + }, expr.loc), + }) catch unreachable; + } args[1] = p.e(E.Object{ .properties = props.toOwnedSlice(), |