From 4ab5be6ba44e3a0646a2a289e0649decbe9675f3 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 20 Jul 2021 15:42:04 -0600 Subject: [PATCH] fix logic error in `reconcile_fragments` I noticed when using the `Keyed` component that when the `KeyedProps::iterable` value changed from a large `Vec` to a smaller one containing a subset of the original, not all the obsolete nodes were removed from the DOM. Specifically, I started with a `Vec` with 10 elements, then removed all but the third one. The nodes before the remaining node were removed, but not the ones after it. This patch fixes the problem. --- packages/sycamore/src/utils/render.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sycamore/src/utils/render.rs b/packages/sycamore/src/utils/render.rs index e69f7c128..6a789f935 100644 --- a/packages/sycamore/src/utils/render.rs +++ b/packages/sycamore/src/utils/render.rs @@ -273,7 +273,7 @@ pub fn reconcile_fragments(parent: &G, a: &mut [G], b: &[G]) { } else if b_end == b_start { // Remove. while a_start < a_end { - if map.is_none() || map.as_ref().unwrap().contains_key(&a[a_start]) { + if map.is_none() || !map.as_ref().unwrap().contains_key(&a[a_start]) { parent.remove_child(&a[a_start]); } a_start += 1;