fix: setnode method for rehydration code

This commit is contained in:
Jonathan Kelley committed 2022-03-17 10:51:23 -04:00
1 parent 014eb974f7
commit f26f704b6b
6 files changed
+61 -30

No files matched your search

+33 -9
View File
@@ -2,6 +2,7 @@ use dioxus_core::prelude::*;
use dioxus_core_macro::*;
use dioxus_html as dioxus_elements;
use wasm_bindgen_test::wasm_bindgen_test;
use web_sys::window;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
@@ -10,10 +11,12 @@ fn makes_tree() {
fn app(cx: Scope) -> Element {
cx.render(rsx! {
div {
h1 {}
}
div {
h2 {}
div {
h1 {}
}
div {
h2 {}
}
}
})
}
@@ -29,13 +32,34 @@ fn rehydrates() {
fn app(cx: Scope) -> Element {
cx.render(rsx! {
div {
h1 {}
}
div {
h2 {}
div {
h1 { "h1" }
}
div {
h2 { "h2" }
}
button {
onclick: move |_| {
println!("clicked");
},
"listener test"
}
false.then(|| rsx!{ "hello" })
}
})
}
dioxus_web::launch(app);
let mut dom = VirtualDom::new(app);
let _ = dom.rebuild();
let out = dioxus_ssr::render_vdom_cfg(&dom, |c| c.pre_render(true));
window()
.unwrap()
.document()
.unwrap()
.body()
.unwrap()
.set_inner_html(&format!("<div id='main'>{}</div>", out));
dioxus_web::launch_cfg(app, |c| c.hydrate(true));
}