Skip to content

Commit

Permalink
fix: whitespace for single component child (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Oct 26, 2023
1 parent c7b8b21 commit 079f992
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/transpiling/jsx_precompile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ impl JsxPrecompile {
let child = &children[0];
match child {
JSXElementChild::JSXText(jsx_text) => {
Some(string_lit_expr(jsx_text.value.to_string()))
let text = jsx_text_to_str(jsx_text);
Some(string_lit_expr(text))
}
JSXElementChild::JSXExprContainer(jsx_expr_container) => {
match &jsx_expr_container.expr {
Expand Down Expand Up @@ -1546,6 +1547,17 @@ const $$_tpl_1 = [
];
const a = _jsx(Foo, {
children: _jsxssr($$_tpl_1)
});"#,
);

test_transform(
JsxPrecompile::default(),
r#"const a = <Foo>
foo
</Foo>;"#,
r#"import { jsx as _jsx } from "react/jsx-runtime";
const a = _jsx(Foo, {
children: "foo"
});"#,
);
}
Expand Down

0 comments on commit 079f992

Please sign in to comment.