From 5f2b92c267372cf08c2d2323ec330e90bd12b2f5 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Mon, 1 Aug 2022 18:42:33 -0400 Subject: [PATCH] =?UTF-8?q?Without=20a=20doubt,=20this=20is=20the=20stupid?= =?UTF-8?q?est=20and=20most=20frustrating=20bug=20I've=20ever=20created.?= =?UTF-8?q?=20Essentially,=20DOM=20nodes=20weren't=20being=20replaced=20or?= =?UTF-8?q?=20removed=20correctly=20because=20`current`=20was=20stuck=20on?= =?UTF-8?q?=20its=20origins=20in=20a=20DocumentFragment.=20It=20looked=20l?= =?UTF-8?q?ike=20some=20frustrating=20situation=20in=20which=20returns=20f?= =?UTF-8?q?rom=20appendChild=20were=20still=20referring=20back=20to=20the?= =?UTF-8?q?=20fragment,=20etc.=20No=20=E2=80=94=20I=20just=20literally=20w?= =?UTF-8?q?asn't=20ever=20using=20the=20return=20value,=20and=20instead=20?= =?UTF-8?q?was=20using=20the=20original=20value=20from=20the=20function=20?= =?UTF-8?q?call.=20Ridiculous,=20but=20so=20satisfying=20when=20it=20sudde?= =?UTF-8?q?nly=20fixed=20a=20bunch=20of=20issues.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO.md | 2 -- leptos_dom/src/render.rs | 13 ++++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index ee2e98739..b4fe2e4e3 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,5 @@ - [ ] Async - [x] Resource - - [ ] Render bug: when doing e.g., a `match` and having multiple branches with separate `template`s, all exist as separate document fragment and replace the fragment, not one another -- find a way to make sure that `Child<'a>` returned from `insert` is _actually_ attached to the DOM - - [ ] Render bug with list reconciliation - [ ] Suspense - [ ] Docs (and clippy warning to insist on docs) - [ ] Read through + understand... diff --git a/leptos_dom/src/render.rs b/leptos_dom/src/render.rs index c353d592e..6727d86d0 100644 --- a/leptos_dom/src/render.rs +++ b/leptos_dom/src/render.rs @@ -98,15 +98,12 @@ pub fn insert<'a>( value = f(); } - insert_expression( + current = Some(insert_expression( parent.clone().unchecked_into(), &f(), current.clone().unwrap_or(Child::Null), - //current.get_untracked().clone(), // get untracked to avoid infinite loop when we set current, below before.as_ref(), - ); - - current = Some(value); + )); }); } _ => { @@ -132,6 +129,12 @@ pub fn insert_expression<'a>( parent.node_name(), current ); + if let Child::Node(node) = ¤t { + crate::log!( + "current's parent = {}", + node.parent_node().unwrap().node_name() + ); + } if new_value == ¤t { current