diff options
author | 2023-05-19 18:22:54 -0700 | |
---|---|---|
committer | 2023-05-19 18:22:54 -0700 | |
commit | 9306103949230dfc8858bc4d2cc2d3105bdb3e8c (patch) | |
tree | 38c079db63126fa94199cf688e2bdd0be428764e /src/js_parser.zig | |
parent | 12d841a3f5d227e6ab19bf4defc2a8e63e8ba1b6 (diff) | |
download | bun-9306103949230dfc8858bc4d2cc2d3105bdb3e8c.tar.gz bun-9306103949230dfc8858bc4d2cc2d3105bdb3e8c.tar.zst bun-9306103949230dfc8858bc4d2cc2d3105bdb3e8c.zip |
make sure `key` is added to args (#2968)
Diffstat (limited to 'src/js_parser.zig')
-rw-r--r-- | src/js_parser.zig | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig index ee6a5e6b8..31e036bbb 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -15097,21 +15097,19 @@ fn NewParser_( // There are at least two args: // - name of the tag // - props - var i: usize = 1; + var i: usize = 2; args[0] = tag; - if (e_.properties.len > 0) { + + const num_props = e_.properties.len + @boolToInt(e_.key != null); + if (num_props > 0) { + var props = p.allocator.alloc(G.Property, num_props) catch unreachable; + bun.copy(G.Property, props, e_.properties.slice()); if (e_.key) |key| { - var props = p.allocator.alloc(G.Property, e_.properties.len + 1) catch unreachable; - bun.copy(G.Property, props, e_.properties.slice()); props[props.len - 1] = G.Property{ .key = Expr{ .loc = key.loc, .data = keyExprData }, .value = key }; - args[1] = p.newExpr(E.Object{ .properties = G.Property.List.init(props) }, expr.loc); - } else { - args[1] = p.newExpr(E.Object{ .properties = e_.properties }, expr.loc); } - i = 2; + args[1] = p.newExpr(E.Object{ .properties = G.Property.List.init(props) }, expr.loc); } else { args[1] = p.newExpr(E.Null{}, expr.loc); - i = 2; } const children_elements = e_.children.slice()[0..children_count]; |