Skip to content

Commit

Permalink
fix: allow temporaries as props (closes leptos-rs#2541) (leptos-rs#2582)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj authored May 8, 2024
1 parent f3f3a05 commit 3760ced
Show file tree
Hide file tree
Showing 13 changed files with 430 additions and 1,311 deletions.
22 changes: 7 additions & 15 deletions leptos_macro/src/view/component_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,25 +237,17 @@ pub(crate) fn component_to_tokens(

#[allow(unused_mut)] // used in debug
let mut component = quote_spanned! {node.span()=>
{
let props = #component_props_builder
::leptos::component_view(
#[allow(clippy::needless_borrows_for_generic_args)]
#name_ref,
#component_props_builder
#(#props)*
#(#slots)*
#children;

#[allow(clippy::let_unit_value, clippy::unit_arg)]
let props = props
#children
#build
#dyn_attrs
#(#spread_bindings)*;

#[allow(unreachable_code)]
::leptos::component_view(
#[allow(clippy::needless_borrows_for_generic_args)]
#name_ref,
props
)
}
#(#spread_bindings)*
)
};

// (Temporarily?) removed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
---
source: leptos_macro/src/view/tests.rs
assertion_line: 101
expression: pretty(result)
---
fn view() {
{
let props = ::leptos::component_props_builder(&SimpleCounter)
::leptos::component_view(
#[allow(clippy::needless_borrows_for_generic_args)]
&SimpleCounter,
::leptos::component_props_builder(&SimpleCounter)
.initial_value(#[allow(unused_braces)] { 0 })
.step(#[allow(unused_braces)] { 1 });
#[allow(clippy::let_unit_value, clippy::unit_arg)]
let props = props.build();
#[allow(unreachable_code)]
::leptos::component_view(
#[allow(clippy::needless_borrows_for_generic_args)]
&SimpleCounter,
props,
)
}
.step(#[allow(unused_braces)] { 1 })
.build(),
)
}

Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
---
source: leptos_macro/src/view/tests.rs
assertion_line: 101
expression: pretty(result)
---
fn view() {
::leptos::IntoView::into_view(
#[allow(unused_braces)]
{
{
let props = ::leptos::component_props_builder(&ExternalComponent);
#[allow(clippy::let_unit_value, clippy::unit_arg)]
let props = props.build();
#[allow(unreachable_code)]
::leptos::component_view(
#[allow(clippy::needless_borrows_for_generic_args)]
&ExternalComponent,
props,
)
}
::leptos::component_view(
#[allow(clippy::needless_borrows_for_generic_args)]
&ExternalComponent,
::leptos::component_props_builder(&ExternalComponent).build(),
)
},
)
.on(
Expand All @@ -27,4 +20,3 @@ fn view() {
move |_: Event| set_value(0),
)
}

Loading

0 comments on commit 3760ced

Please sign in to comment.