Skip to content

Commit

Permalink
fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Mar 19, 2024
1 parent 398ed07 commit 8f95e7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
18 changes: 3 additions & 15 deletions src/diff/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ export function diffChildren(
childVNode._flags & INSERT_VNODE ||
oldVNode._children === childVNode._children
) {
if (!newDom && oldVNode._dom == oldDom) {
oldDom = getDomSibling(oldVNode);
}
oldDom = insert(childVNode, oldDom, parentDom);
} else if (
typeof childVNode.type == 'function' &&
Expand Down Expand Up @@ -229,11 +232,6 @@ function constructNewChildrenArray(newParentVNode, renderResult, oldChildren) {

const skewedIndex = i + skew;

console.log(
'hi',
childVNode && childVNode.type,
childVNode && childVNode.key
);
// Handle unmounting null placeholders, i.e. VNode => null in unkeyed children
if (childVNode == null) {
oldVNode = oldChildren[skewedIndex];
Expand All @@ -244,17 +242,8 @@ function constructNewChildrenArray(newParentVNode, renderResult, oldChildren) {
(oldVNode._flags & MATCHED) === 0
) {
if (oldVNode._dom == newParentVNode._nextDom) {
console.log(newParentVNode._parent._nextDom);
if (newParentVNode._parent._nextDom === oldVNode._dom) {
newParentVNode._parent._nextDom = getDomSibling(oldVNode);
}
newParentVNode._nextDom = getDomSibling(oldVNode);
}
console.log(
'setting early unmount',
newParentVNode.type,
newParentVNode._nextDom
);

unmount(oldVNode, oldVNode, false);

Expand Down Expand Up @@ -386,7 +375,6 @@ function insert(parentVNode, oldDom, parentDom) {
oldDom = oldDom && oldDom.nextSibling;
} while (oldDom != null && oldDom.nodeType === 8);

console.log('returning from insert', oldDom);
return oldDom;
}

Expand Down
3 changes: 1 addition & 2 deletions test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ describe('render()', () => {
);
});

it.only('should shrink lists', () => {
it('should shrink lists', () => {
function RenderedItem({ item }) {
if (item.renderAsNullInComponent) {
return null;
Expand Down Expand Up @@ -1576,7 +1576,6 @@ describe('render()', () => {
'<div><div>One</div><div>Two</div><div>Three</div><div>Four</div></div>'
);

console.log('---');
render(<App list={secondList} />, scratch);
expect(scratch.innerHTML).to.equal(
'<div><div>One</div><div>Six</div><div>Seven</div></div>'
Expand Down

0 comments on commit 8f95e7e

Please sign in to comment.