Skip to content

Commit

Permalink
fixup of Collectable
Browse files Browse the repository at this point in the history
  • Loading branch information
WorldSEnder committed May 7, 2022
1 parent 5a2ef78 commit 27e06ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/yew/src/html/component/scope.rs
Expand Up @@ -289,11 +289,7 @@ mod feat_ssr {
);
scheduler::start();

#[cfg(debug_assertions)]
let collectable = Collectable::Component(std::any::type_name::<COMP>());

#[cfg(not(debug_assertions))]
let collectable = Collectable::Component;
let collectable = Collectable::for_component::<COMP>();

if hydratable {
collectable.write_open_tag(w);
Expand Down Expand Up @@ -632,10 +628,7 @@ mod feat_hydration {
format!("hydration(type = {})", std::any::type_name::<COMP>()),
);

#[cfg(debug_assertions)]
let collectable = Collectable::Component(std::any::type_name::<COMP>());
#[cfg(not(debug_assertions))]
let collectable = Collectable::Component;
let collectable = Collectable::for_component::<COMP>();

let fragment = Fragment::collect_between(fragment, &collectable, &parent);
node_ref.set(fragment.front().cloned());
Expand Down
9 changes: 9 additions & 0 deletions packages/yew/src/virtual_dom/mod.rs
Expand Up @@ -208,6 +208,7 @@ mod feat_ssr_hydration {
type ComponentName = &'static str;
#[cfg(not(debug_assertions))]
type ComponentName = ();

/// A collectable.
///
/// This indicates a kind that can be collected from fragment to be processed at a later time
Expand All @@ -217,6 +218,14 @@ mod feat_ssr_hydration {
}

impl Collectable {
pub fn for_component<T: 'static>() -> Self {
#[cfg(debug_assertions)]
let comp_name = std::any::type_name::<T>();
#[cfg(not(debug_assertions))]
let comp_name = ();
Self::Component(comp_name)
}

pub fn open_start_mark(&self) -> &'static str {
match self {
Self::Component(_) => "<[",
Expand Down

0 comments on commit 27e06ba

Please sign in to comment.