always load the templates in hydration

This commit is contained in:
Evan Almloff committed 2023-01-31 14:18:34 -06:00
1 parent 696109db10
commit 9baef6bcd9
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ pub struct Mutations<'a> {
/// Any templates encountered while diffing the DOM.
///
/// These must be loaded into a cache before applying the edits
pub templates: Vec<Template<'static>>,
pub templates: Vec<Template<'a>>,
/// Any mutations required to patch the renderer to match the layout of the VirtualDom
pub edits: Vec<Mutation<'a>>,
+2 -2
View File
@@ -198,8 +198,9 @@ pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_prop
// todo: we need to split rebuild and initialize into two phases
// it's a waste to produce edits just to get the vdom loaded
// we need to save the templates in case hydration fails
let templates = dom.rebuild().templates;
websys_dom.load_templates(&templates);
if let Err(err) = websys_dom.rehydrate(&dom) {
log::error!(
"Rehydration failed {:?}. Rebuild DOM into element from scratch",
@@ -209,7 +210,6 @@ pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_prop
let edits = dom.rebuild();
websys_dom.load_templates(&templates);
websys_dom.load_templates(&edits.templates);
websys_dom.apply_edits(edits.edits);
}