aboutsummaryrefslogtreecommitdiff
path: root/src/js_parser/js_parser.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-17 15:25:36 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-17 15:25:36 -0700
commit3b6259edf33933be61ed0e8cdb2ff3dc2ae3a56a (patch)
tree48a0aa9e2d8c099e381332e3be5d23da61e7e371 /src/js_parser/js_parser.zig
parentae01e9b98d481332236976344fa0386bafa82f53 (diff)
downloadbun-3b6259edf33933be61ed0e8cdb2ff3dc2ae3a56a.tar.gz
bun-3b6259edf33933be61ed0e8cdb2ff3dc2ae3a56a.tar.zst
bun-3b6259edf33933be61ed0e8cdb2ff3dc2ae3a56a.zip
fix jsx
Former-commit-id: a9bfcbce261798cdd0c3f8cb09076dc246920b48
Diffstat (limited to 'src/js_parser/js_parser.zig')
-rw-r--r--src/js_parser/js_parser.zig30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig
index 4d6189cbc..78ab4feb3 100644
--- a/src/js_parser/js_parser.zig
+++ b/src/js_parser/js_parser.zig
@@ -10484,7 +10484,7 @@ pub fn NewParser(
}
}
- const runtime = if (p.options.jsx.runtime == .automatic and !e_.flags.is_key_before_rest) options.JSX.Runtime.automatic else options.JSX.Runtime.classic;
+ const runtime = if (e_.tag != null and p.options.jsx.runtime == .automatic and !e_.flags.is_key_before_rest) options.JSX.Runtime.automatic else options.JSX.Runtime.classic;
var children_count = e_.children.len;
const is_childless_tag = FeatureFlags.react_specific_warnings and children_count > 0 and tag.data == .e_string and tag.data.e_string.isUTF8() and js_lexer.ChildlessJSXTags.has(tag.data.e_string.utf8);
@@ -10546,18 +10546,22 @@ pub fn NewParser(
// children: []
// }
- 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;
+ switch (children_count) {
+ 0 => {},
+
+ else => {
+ 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{