Skip to content

Commit

Permalink
Bail a bit later
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Sep 12, 2024
1 parent 0453daa commit f02066b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}
Expand Down Expand Up @@ -625,7 +625,7 @@ export function unmount(vnode, parentVNode, skipRemove) {
}
}

if (!skipRemove && vnode._dom != null) {
if (!skipRemove) {
removeNode(vnode._dom);
}

Expand Down
6 changes: 4 additions & 2 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit f02066b

Please sign in to comment.