Skip to content

Commit 4ffb658

Browse files
committed
easier to read
1 parent c189ade commit 4ffb658

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

demo/lazyBarrier.jsx

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { lazy } from 'react';
2+
3+
export const TestComp = lazy(() => import('./testComp'));
4+
export const TestWrapper = lazy(() => import('./testWrapper'));

demo/testComp.jsx

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const TestComp = () => {
2+
return <p>Bar</p>;
3+
};
4+
5+
export default TestComp;

demo/testWrapper.jsx

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react';
2+
3+
const TestWrapper = ({ children }) => {
4+
return <div>{children}</div>;
5+
};
6+
7+
export default TestWrapper;

src/diff/children.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,7 @@ function constructNewChildrenArray(newParentVNode, renderResult, oldChildren) {
320320
skew--;
321321
}
322322
} else if (matchingIndex < skewedIndex) {
323-
// Our matched DOM-node is further in the negative way in the list of children
324-
// than where it's at now.
325-
326-
// When the remaining old chiildren is less than the new children
327-
// 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-
}
323+
skew--;
333324
}
334325

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

test/browser/render.test.js

+6
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)