From 6801688ed23e91e2a0decdce3dd4353dfe89b9e6 Mon Sep 17 00:00:00 2001 From: jdecroock Date: Sun, 12 May 2019 15:28:13 +0200 Subject: [PATCH] feat: add poc solution --- src/diff/children.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/diff/children.js b/src/diff/children.js index c18d786658..f1bb368ee4 100644 --- a/src/diff/children.js +++ b/src/diff/children.js @@ -33,6 +33,15 @@ export function diffChildren(parentDom, newParentVNode, oldParentVNode, context, let oldChildrenLength = oldChildren.length; + // POC: solution + if (newChildren.length > oldChildren.length) { + // TODO: we only need a way to find this newIndex... + let newIndex = 0; + if (newIndex) { + oldChildren.splice(newIndex, 0, null); + } + } + // Only in very specific places should this logic be invoked (top level `render` and `diffElementNodes`). // I'm using `EMPTY_OBJ` to signal when `diffChildren` is invoked in these situations. I can't use `null` // for this purpose, because `null` is a valid value for `oldDom` which can mean to skip to this logic