Skip to content

Commit

Permalink
Fix parenthesizing of expressions in view! interpolation syntax (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechu10 authored Nov 26, 2021
1 parent 6b739b8 commit 31050ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/sycamore-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ quote = "1.0.10"
syn = "1.0.81"

[dev-dependencies]
sycamore = { path = "../sycamore" }
sycamore = { path = "../sycamore", features = ["experimental-hydrate"] }
trybuild = "1.0.52"

[features]
Expand Down
8 changes: 4 additions & 4 deletions packages/sycamore-macro/src/view/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl ToTokens for Element {
quote_spanned! { splice.span()=>
::sycamore::utils::render::insert(
&__el,
::sycamore::view::IntoView::create(&#splice),
::sycamore::view::IntoView::create(&(#splice)),
None, None, #multi
);
}
Expand Down Expand Up @@ -215,7 +215,7 @@ impl ToTokens for Element {
::sycamore::utils::render::insert(
&__el,
::sycamore::view::View::new_dyn(move ||
::sycamore::view::IntoView::create(&#splice)
::sycamore::view::IntoView::create(&(#splice))
),
#initial, Some(&__end_marker), #multi
);
Expand All @@ -225,7 +225,7 @@ impl ToTokens for Element {
::sycamore::utils::render::insert(
&__el,
::sycamore::view::View::new_dyn(move ||
::sycamore::view::IntoView::create(&#splice)
::sycamore::view::IntoView::create(&(#splice))
),
#initial, __marker, #multi
);
Expand All @@ -248,7 +248,7 @@ impl ToTokens for Element {
::sycamore::utils::render::insert(
&__el,
::sycamore::view::View::new_dyn(move ||
::sycamore::view::IntoView::create(&#splice)
::sycamore::view::IntoView::create(&(#splice))
),
#initial, __marker, #multi
);
Expand Down
3 changes: 3 additions & 0 deletions packages/sycamore-macro/tests/view/element-pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ fn compile_pass<G: GenericNode>() {
let _: View<G> = view! { button(class="my-btn", aria-hidden="true") };

let _: View<G> = view! { p(dangerously_set_inner_html="<span>Test</span>") };

// view! should correctly parenthesize the (1 + 2) when borrowing.
let _: View<G> = view! { p { (1 + 2) } };
}

fn main() {}

1 comment on commit 31050ae

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.

Benchmark suite Current: 31050ae Previous: 6b739b8 Ratio
reactivity_signals 48887 ns/iter (± 1033) 35567 ns/iter (± 223) 1.37

This comment was automatically generated by workflow using github-action-benchmark.

CC: @lukechu10

Please sign in to comment.