From 8cfee1cd740638de4139812ef12ca6b9038de1eb Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Thu, 19 May 2022 11:29:48 -0700 Subject: [PATCH 1/2] fix: only remove slot children in synthetic shadow --- packages/@lwc/engine-core/src/framework/rendering.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/@lwc/engine-core/src/framework/rendering.ts b/packages/@lwc/engine-core/src/framework/rendering.ts index 408713dc29..c560c58ac8 100644 --- a/packages/@lwc/engine-core/src/framework/rendering.ts +++ b/packages/@lwc/engine-core/src/framework/rendering.ts @@ -284,7 +284,9 @@ function unmount(vnode: VNode, parent: ParentNode, doRemove: boolean = false) { removeNode(elm!, parent); } - const removeChildren = sel === 'slot'; // slot content is removed to trigger slotchange event when removing slot + // Slot content is removed to trigger slotchange event when removing slot. + // Only required for synthetic shadow. + const removeChildren = sel === 'slot' && vnode.owner.shadowMode === ShadowMode.Synthetic; switch (type) { case VNodeType.Element: unmountVNodes(vnode.children, elm as ParentNode, removeChildren); From 42c37c527a4ee346eb0472009c11cad37ba91481 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Tue, 24 May 2022 11:45:21 -0700 Subject: [PATCH 2/2] fix: use case block --- packages/@lwc/engine-core/src/framework/rendering.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/@lwc/engine-core/src/framework/rendering.ts b/packages/@lwc/engine-core/src/framework/rendering.ts index c560c58ac8..5c30f34a55 100644 --- a/packages/@lwc/engine-core/src/framework/rendering.ts +++ b/packages/@lwc/engine-core/src/framework/rendering.ts @@ -284,13 +284,15 @@ function unmount(vnode: VNode, parent: ParentNode, doRemove: boolean = false) { removeNode(elm!, parent); } - // Slot content is removed to trigger slotchange event when removing slot. - // Only required for synthetic shadow. - const removeChildren = sel === 'slot' && vnode.owner.shadowMode === ShadowMode.Synthetic; switch (type) { - case VNodeType.Element: + case VNodeType.Element: { + // Slot content is removed to trigger slotchange event when removing slot. + // Only required for synthetic shadow. + const removeChildren = + sel === 'slot' && vnode.owner.shadowMode === ShadowMode.Synthetic; unmountVNodes(vnode.children, elm as ParentNode, removeChildren); break; + } case VNodeType.CustomElement: { const { vm } = vnode;