Skip to content

Commit c6268f2

Browse files
committed
easier to read
1 parent c189ade commit c6268f2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/diff/children.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,7 @@ function constructNewChildrenArray(newParentVNode, renderResult, oldChildren) {
325325

326326
// When the remaining old chiildren is less than the new children
327327
// plus our skewed index we know we are dealing with a growing list
328-
if (remainingOldChildren < newChildrenLength + skewedIndex) {
329-
skew += matchingIndex + skewedIndex;
330-
} else {
331-
skew = 0;
332-
}
328+
skew -= matchingIndex - skewedIndex;
333329
}
334330

335331
// Move this VNode's DOM if the original index (matchingIndex) doesn't

test/browser/render.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,7 @@ describe('render()', () => {
16361636
);
16371637
const a = ['0', '1', '2', '3', '4', '5', '6'];
16381638
const b = ['1', '3', '5', '2', '6', '4', '0'];
1639+
const c = ['11', '3', '1', '4', '6', '2', '5', '0', '9', '10'];
16391640
render(<App items={a} />, scratch);
16401641
expect(scratch.innerHTML).to.equal(
16411642
`<div>${a.map(n => `<div>${n}</div>`).join('')}</div>`
@@ -1646,6 +1647,11 @@ describe('render()', () => {
16461647
`<div>${b.map(n => `<div>${n}</div>`).join('')}</div>`
16471648
);
16481649

1650+
render(<App items={c} />, scratch);
1651+
expect(scratch.innerHTML).to.equal(
1652+
`<div>${c.map(n => `<div>${n}</div>`).join('')}</div>`
1653+
);
1654+
16491655
render(<App items={a} />, scratch);
16501656
expect(scratch.innerHTML).to.equal(
16511657
`<div>${a.map(n => `<div>${n}</div>`).join('')}</div>`

0 commit comments

Comments
 (0)