Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swc-plugin-nullstack",
"version": "0.1.3",
"version": "0.1.4",
"description": "SWC plugin for Nullstack",
"main": "./dist/swc-plugin-nullstack.wasm",
"author": "Mortaro",
Expand Down
1 change: 1 addition & 0 deletions src/loaders/inject_inner_components_to_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ impl VisitMut for InjectInnerComponentVisitor {
self.is_inside_tag = true;
n.name.visit_mut_children_with(self);
self.is_inside_tag = false;
n.visit_mut_children_with(self);
}
}

Expand Down
47 changes: 47 additions & 0 deletions src/tests/inject_inner_components_to_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,4 +590,51 @@ test!(
}
}
"#
);

test!(
syntax(),
|_| tr(InjectInnerComponentVisitor::default()),
inject_inner_components_when_passed_as_props,
r#"
const OtherComponent = () => {}
class Component {
renderInnerComponent() { return false }
render() {
return <OtherComponent prop={<InnerComponent />} />
}
}
"#,
r#"
const OtherComponent = () => {}
class Component {
renderInnerComponent() { return false }
render() {
const InnerComponent = this.renderInnerComponent
return <OtherComponent prop={<InnerComponent />} />
}
}
"#
);

test!(
syntax(),
|_| tr(InjectInnerComponentVisitor::default()),
skip_inject_inner_components_when_passed_as_props_that_should_be_regular_constant,
r#"
const OtherComponent = () => {}
class Component {
render() {
return <OtherComponent prop={String("na" + "de" + "ga")} />
}
}
"#,
r#"
const OtherComponent = () => {}
class Component {
render() {
return <OtherComponent prop={String("na" + "de" + "ga")} />
}
}
"#
);