mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
parent
1368a4a281
commit
59f6a6ffb6
@ -266,6 +266,14 @@ impl Fold<Expr> for Jsx {
|
||||
// <div></div> => React.createElement('div', null);
|
||||
self.jsx_elem_to_expr(el)
|
||||
}
|
||||
Expr::Paren(ParenExpr {
|
||||
expr: box Expr::JSXFragment(frag),
|
||||
..
|
||||
})
|
||||
| Expr::JSXFragment(frag) => {
|
||||
// <></> => React.createElement(React.Fragment, null);
|
||||
self.jsx_frag_to_expr(frag)
|
||||
}
|
||||
_ => expr,
|
||||
}
|
||||
}
|
||||
|
@ -1024,3 +1024,19 @@ var div = React.createElement(Component, Object.assign({}, props, {
|
||||
}));
|
||||
"#
|
||||
);
|
||||
|
||||
test!(
|
||||
::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig {
|
||||
jsx: true,
|
||||
..Default::default()
|
||||
}),
|
||||
|_| tr(Options {
|
||||
use_builtins: true,
|
||||
..Default::default()
|
||||
},),
|
||||
issue_229,
|
||||
"const a = <>test</>
|
||||
const b = <div>test</div>",
|
||||
"const a = React.createElement(React.Fragment, null, 'test');
|
||||
const b = React.createElement('div', null, 'test');"
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user