Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export function diff(

newVNode._dom = oldVNode._dom;
newVNode._children = oldVNode._children;
newVNode._children.forEach(vnode => {
newVNode._children.some(vnode => {
if (vnode) vnode._parent = newVNode;
});

Expand Down Expand Up @@ -455,7 +455,7 @@ function diffElementNodes(
if (i == 'children') {
} else if (i == 'dangerouslySetInnerHTML') {
oldHtml = value;
} else if (i !== 'key' && !(i in newProps)) {
} else if (!(i in newProps)) {
if (
(i == 'value' && 'defaultValue' in newProps) ||
(i == 'checked' && 'defaultChecked' in newProps)
Expand All @@ -479,7 +479,6 @@ function diffElementNodes(
} else if (i == 'checked') {
checked = value;
} else if (
i !== 'key' &&
(!isHydrating || typeof value == 'function') &&
oldProps[i] !== value
) {
Expand Down Expand Up @@ -524,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 @@ -626,7 +625,7 @@ export function unmount(vnode, parentVNode, skipRemove) {
}
}

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

Expand Down
3 changes: 1 addition & 2 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ 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 && node.parentNode) node.parentNode.removeChild(node);
}

export const slice = EMPTY_ARR.slice;