Skip to content

Commit

Permalink
Ensure all nodes are used when multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
tbranyen committed Mar 23, 2021
1 parent 131e739 commit 4048509
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/diffhtml/lib/tasks/reconcile-trees.js
Expand Up @@ -30,6 +30,7 @@ export default function reconcileTrees(transaction) {
}

const { nodeName, attributes } = state.oldTree;
const inputAsVTree = /** @type {VTree} */(input);

// TODO When `inner === false` this means we are doing outerHTML operation.
// The way this works is that anything that doesn't match the oldTree element
Expand All @@ -47,15 +48,14 @@ export default function reconcileTrees(transaction) {
// without needing to trim.
if (
!inner &&
/** @type {VTree} */(input).nodeType === NODE_TYPE.FRAGMENT &&
inputAsVTree.nodeType === NODE_TYPE.FRAGMENT &&
// Do not modify the new children when comparing two fragments.
state.oldTree.nodeType !== NODE_TYPE.FRAGMENT
) {
/** @type {VTree[]} */
let foundElements = [];

/** @type {VTree} */
(input).childNodes.forEach((/** @type {VTree} */ value) => {
inputAsVTree.childNodes.forEach(value => {
const isText = value.nodeType === NODE_TYPE.TEXT;

// This is most likely the element that is requested to compare to. Will
Expand All @@ -71,7 +71,7 @@ export default function reconcileTrees(transaction) {
}
// Otherwise consider the entire fragment.
else if (foundElements.length > 1) {
transaction.newTree = createTree(foundElements);
transaction.newTree = createTree(inputAsVTree.childNodes);
}
}

Expand Down

0 comments on commit 4048509

Please sign in to comment.