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
1 change: 1 addition & 0 deletions src/diff/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ function constructNewChildrenArray(
remainingOldChildren
));

oldVNode = NULL;
if (matchingIndex != -1) {
oldVNode = oldChildren[matchingIndex];
remainingOldChildren--;
Expand Down
23 changes: 23 additions & 0 deletions test/browser/keys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1128,4 +1128,27 @@ describe('keys', () => {
render(<App y="2" />, scratch);
expect(actions).to.deep.equal(['mounted 1', 'mounted 2', 'mounted 3']);
});

// Issue #4973: Test growing list diff
it('should correctly diff a growing list of keyed children', () => {
let values = [0, 1, 2, 3, 4];

render(<List values={values} />, scratch);
expect(scratch.textContent).to.equal('01234');

values = [2, 3, 4, 5, 6];
clearLog();

render(<List values={values} />, scratch);
expect(scratch.textContent).to.equal('23456');

expect(getLog()).to.deep.equal([
'<li>0.remove()',
'<li>1.remove()',
'<li>.appendChild(#text)',
'<ol>234.appendChild(<li>5)',
'<li>.appendChild(#text)',
'<ol>2345.appendChild(<li>6)'
]);
});
});
Loading