fixed `DynChild` panicking when expected text is not there
This commit is contained in:
parent
d158c34d24
commit
a5d7563a67
|
@ -11,7 +11,7 @@ pub fn App(cx: Scope) -> impl IntoView {
|
|||
if cfg!(feature = "ssr") {
|
||||
let (tx, rx) = futures::channel::oneshot::channel();
|
||||
spawn_local(async {
|
||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
||||
tx.send(());
|
||||
});
|
||||
rx.await;
|
||||
|
@ -26,17 +26,15 @@ pub fn App(cx: Scope) -> impl IntoView {
|
|||
<div>
|
||||
"This is some text"
|
||||
</div>
|
||||
<Suspense fallback=move || view! { cx, <p>"Loading..."</p> }>
|
||||
// <Suspense fallback=move || view! { cx, <p>"Loading..."</p> }>
|
||||
{move || pending_thing.read().map(|n| view! { cx, <ComponentA/> })}
|
||||
</Suspense>
|
||||
// </Suspense>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn ComponentA(
|
||||
cx: Scope,
|
||||
) -> impl IntoView {
|
||||
pub fn ComponentA(cx: Scope) -> impl IntoView {
|
||||
let (value, set_value) = create_signal(cx, "Hello?".to_string());
|
||||
let (counter, set_counter) = create_signal(cx, 0);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use cfg_if::cfg_if;
|
||||
use crate::{hydration::HydrationCtx, Comment, IntoView, View};
|
||||
use cfg_if::cfg_if;
|
||||
use leptos_reactive::Scope;
|
||||
use std::{borrow::Cow, cell::RefCell, fmt, ops::Deref, rc::Rc};
|
||||
cfg_if! {
|
||||
|
@ -233,23 +233,22 @@ where
|
|||
else {
|
||||
// We need to remove the text created from SSR
|
||||
if HydrationCtx::is_hydrating() && new_child.get_text().is_some() {
|
||||
let t = closing
|
||||
.previous_sibling()
|
||||
.unwrap()
|
||||
.unchecked_into::<web_sys::Element>();
|
||||
if let Some(t) = closing.previous_sibling() {
|
||||
let t = t.unchecked_into::<web_sys::Element>();
|
||||
|
||||
// See note on ssr.rs when matching on `DynChild`
|
||||
// for more details on why we need to do this for
|
||||
// release
|
||||
if !cfg!(debug_assertions) {
|
||||
t.previous_sibling()
|
||||
.unwrap()
|
||||
.unchecked_into::<web_sys::Element>()
|
||||
.remove();
|
||||
// See note on ssr.rs when matching on `DynChild`
|
||||
// for more details on why we need to do this for
|
||||
// release
|
||||
if !cfg!(debug_assertions) {
|
||||
t.previous_sibling()
|
||||
.unwrap()
|
||||
.unchecked_into::<web_sys::Element>()
|
||||
.remove();
|
||||
}
|
||||
|
||||
t.remove();
|
||||
}
|
||||
|
||||
t.remove();
|
||||
|
||||
mount_child(MountKind::Before(&closing), &new_child);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue