From f02066bbaee97155d1c6d6379f3160c43c666eb2 Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Thu, 12 Sep 2024 19:04:50 +0200 Subject: [PATCH] Bail a bit later --- src/diff/index.js | 4 ++-- src/util.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/diff/index.js b/src/diff/index.js index b72a368432..f36530110f 100644 --- a/src/diff/index.js +++ b/src/diff/index.js @@ -523,7 +523,7 @@ function diffElementNodes( // Remove children that are not part of any vnode. if (excessDomChildren != null) { for (i = excessDomChildren.length; i--; ) { - if (excessDomChildren[i] != null) removeNode(excessDomChildren[i]); + removeNode(excessDomChildren[i]); } } } @@ -625,7 +625,7 @@ export function unmount(vnode, parentVNode, skipRemove) { } } - if (!skipRemove && vnode._dom != null) { + if (!skipRemove) { removeNode(vnode._dom); } diff --git a/src/util.js b/src/util.js index 1279b34d30..02688a1d1d 100644 --- a/src/util.js +++ b/src/util.js @@ -22,8 +22,10 @@ export function assign(obj, props) { * @param {preact.ContainerNode} node The node to remove */ export function removeNode(node) { - let parentNode = node.parentNode; - if (parentNode) parentNode.removeChild(node); + if (node) { + let parentNode = node.parentNode; + if (parentNode) parentNode.removeChild(node); + } } export const slice = EMPTY_ARR.slice;