From 27e06ba6124289f24b00ea73e7c043a62ee769d7 Mon Sep 17 00:00:00 2001 From: Martin Molzer Date: Sat, 7 May 2022 03:05:12 +0200 Subject: [PATCH] fixup of Collectable --- packages/yew/src/html/component/scope.rs | 11 ++--------- packages/yew/src/virtual_dom/mod.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/yew/src/html/component/scope.rs b/packages/yew/src/html/component/scope.rs index 94362ba9487..fc0865056a5 100644 --- a/packages/yew/src/html/component/scope.rs +++ b/packages/yew/src/html/component/scope.rs @@ -289,11 +289,7 @@ mod feat_ssr { ); scheduler::start(); - #[cfg(debug_assertions)] - let collectable = Collectable::Component(std::any::type_name::()); - - #[cfg(not(debug_assertions))] - let collectable = Collectable::Component; + let collectable = Collectable::for_component::(); if hydratable { collectable.write_open_tag(w); @@ -632,10 +628,7 @@ mod feat_hydration { format!("hydration(type = {})", std::any::type_name::()), ); - #[cfg(debug_assertions)] - let collectable = Collectable::Component(std::any::type_name::()); - #[cfg(not(debug_assertions))] - let collectable = Collectable::Component; + let collectable = Collectable::for_component::(); let fragment = Fragment::collect_between(fragment, &collectable, &parent); node_ref.set(fragment.front().cloned()); diff --git a/packages/yew/src/virtual_dom/mod.rs b/packages/yew/src/virtual_dom/mod.rs index 44064e1f9aa..ff54cfc6f15 100644 --- a/packages/yew/src/virtual_dom/mod.rs +++ b/packages/yew/src/virtual_dom/mod.rs @@ -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 @@ -217,6 +218,14 @@ mod feat_ssr_hydration { } impl Collectable { + pub fn for_component() -> Self { + #[cfg(debug_assertions)] + let comp_name = std::any::type_name::(); + #[cfg(not(debug_assertions))] + let comp_name = (); + Self::Component(comp_name) + } + pub fn open_start_mark(&self) -> &'static str { match self { Self::Component(_) => "<[",