mirror of
https://github.com/leptos-rs/leptos.git
synced 2025-12-27 11:04:40 -05:00
fix: IntoMaybeErased hygiene on view macro (#4071)
This commit is contained in:
@@ -431,7 +431,9 @@ fn element_children_to_tokens(
|
||||
} else if cfg!(feature = "__internal_erase_components") {
|
||||
Some(quote! {
|
||||
.child(
|
||||
leptos::tachys::view::iterators::StaticVec::from(vec![#(#children.into_maybe_erased()),*])
|
||||
::leptos::tachys::view::iterators::StaticVec::from(vec![#(
|
||||
::leptos::prelude::IntoMaybeErased::into_maybe_erased(#children)
|
||||
),*])
|
||||
)
|
||||
})
|
||||
} else if children.len() > 16 {
|
||||
@@ -481,7 +483,9 @@ fn fragment_to_tokens(
|
||||
children.into_iter().next()
|
||||
} else if cfg!(feature = "__internal_erase_components") {
|
||||
Some(quote! {
|
||||
leptos::tachys::view::iterators::StaticVec::from(vec![#(#children.into_maybe_erased()),*])
|
||||
::leptos::tachys::view::iterators::StaticVec::from(vec![#(
|
||||
::leptos::prelude::IntoMaybeErased::into_maybe_erased(#children)
|
||||
),*])
|
||||
})
|
||||
} else if children.len() > 16 {
|
||||
// implementations of various traits used in routing and rendering are implemented for
|
||||
|
||||
@@ -119,3 +119,45 @@ fn returns_static_lifetime() {
|
||||
WithLifetime(WithLifetimeProps::builder().data(&val).build())
|
||||
}
|
||||
}
|
||||
|
||||
// an attempt to catch unhygienic macros regression
|
||||
mod macro_hygiene {
|
||||
// To ensure no relative module path to leptos inside macros.
|
||||
mod leptos {}
|
||||
|
||||
// doing this separately to below due to this being the smallest
|
||||
// unit with the lowest import surface.
|
||||
#[test]
|
||||
fn view() {
|
||||
use ::leptos::IntoView;
|
||||
use ::leptos_macro::{component, view};
|
||||
|
||||
#[component]
|
||||
fn Component() -> impl IntoView {
|
||||
view! {
|
||||
{()}
|
||||
{()}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// may extend this test with other items as necessary.
|
||||
#[test]
|
||||
fn view_into_any() {
|
||||
use ::leptos::{
|
||||
prelude::{ElementChild, IntoAny},
|
||||
IntoView,
|
||||
};
|
||||
use ::leptos_macro::{component, view};
|
||||
|
||||
#[component]
|
||||
fn Component() -> impl IntoView {
|
||||
view! {
|
||||
<div>
|
||||
{().into_any()}
|
||||
{()}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user