Skip to content

Commit

Permalink
Golf down bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Oct 13, 2024
1 parent 354b265 commit 3bf818a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,20 +500,19 @@ function diffElementNodes(
newVNode._children = [];
} else if (typeof newChildren === 'string') {
if (newChildren !== oldProps.children) {
// Unmount any previous children
while (oldVNode._children && (i = oldVNode._children.pop())) {
// Setting textContent on the dom element will unmount all DOM nodes
// of the previous children, so we don't need to remove DOM in this
// call to unmount
unmount(i, oldVNode, true);
}

newVNode._children = [
// @ts-expect-error
createVNode(null, (dom.textContent = newChildren), null, null)
];
// @ts-expect-error
dom.textContent = newChildren;
const vnode = createVNode(null, newChildren, null, null);
newVNode._children = [vnode];
// @ts-expect-error
vnode._dom = dom.firstChild;
newVNode._children[0]._dom = dom.firstChild;
}
} else {
if (oldHtml) dom.innerHTML = '';
Expand Down

0 comments on commit 3bf818a

Please sign in to comment.