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;