Skip to content

Commit

Permalink
add support for nested $ methods
Browse files Browse the repository at this point in the history
  • Loading branch information
benStre committed Nov 28, 2024
1 parent da50245 commit d8a30b6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
21 changes: 20 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,4 +900,23 @@ test!(
console.log(x);
})
"#
);
);



test!(
Syntax::Es(EsSyntax {
jsx: true,
..Default::default()
},),
|_| TransformVisitor,
t56,
r#"<div>
{
array
.filter(item => item > 0)
.map(item => <span>{item}</span>)
}
</div>
"#
);
2 changes: 1 addition & 1 deletion src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ impl TransformVisitor {

let mut args: Vec::<ExprOrSpread> = vec![
ExprOrSpread {
expr: obj,
expr: self.transform_expr_reactive(obj, "_$"),
spread: None
},
ExprOrSpread {
Expand Down
10 changes: 5 additions & 5 deletions tests/__swc_snapshots__/src/lib.rs/t49.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ call(function({ title, icon, children }) {
2,
3
])}
{..._$method([
1,
2,
3
], "map", (item)=><span>{item}</span>)}
{..._$method(_$(()=>[
1,
2,
3
]), "map", (item)=><span>{item}</span>)}
</div>;
});
3 changes: 3 additions & 0 deletions tests/__swc_snapshots__/src/lib.rs/t56.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
{_$method(_$method(array, "filter", (item)=>item > 0), "map", (item)=><span>{item}</span>)}
</div>;

0 comments on commit d8a30b6

Please sign in to comment.