Skip to content

Commit

Permalink
fix component erasure
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj committed Feb 9, 2025
1 parent 05ce9a5 commit 29f3a77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
5 changes: 4 additions & 1 deletion tachys/src/html/element/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::hydration::set_currently_hydrating;
use crate::{
html::attribute::Attribute,
hydration::{failed_to_cast_element, Cursor},
prelude::IntoAttribute,
renderer::{CastFrom, Rndr},
ssr::StreamBuilder,
view::{
Expand Down Expand Up @@ -410,8 +411,10 @@ where
/// Renders an [`Attribute`] (which can be one or more HTML attributes) into an HTML buffer.
pub fn attributes_to_html<At>(attr: At, buf: &mut String) -> String
where
At: Attribute,
At: IntoAttribute,
{
let attr = attr.into_attr();

// `class` and `style` are created first, and pushed later
// this is because they can be filled by a mixture of values that include
// either the whole value (`class="..."` or `style="..."`) and individual
Expand Down
12 changes: 0 additions & 12 deletions tachys/src/view/any_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,23 +322,11 @@ where
}
};

// Without erasure, tuples of attrs created by default cause too much type explosion to enable.
#[cfg(erase_components)]
let add_any_attr = |value: Box<dyn Any>, attr: crate::html::attribute::any_attribute::AnyAttribute| {
let value = value
.downcast::<T>()
.expect("AnyView::add_any_attr could not be downcast");
value.add_any_attr(attr).into_any()
};

AnyView {
type_id: TypeId::of::<T>(),
value,
build,
rebuild,
// Without erasure, tuples of attrs created by default cause too much type explosion to enable.
#[cfg(erase_components)]
add_any_attr,
#[cfg(feature = "ssr")]
resolve,
#[cfg(feature = "ssr")]
Expand Down

0 comments on commit 29f3a77

Please sign in to comment.