-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preact@10.22.0 unexpected child ordering with skew based diff #4412
Comments
@JoviDeCroock Thank you for your timely fix. To Reproduce (in preact unit test)
it('handle shuffled', () => {
function randomize(arr) {
for (let i = arr.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
}
return arr;
}
const App = ({items}) => (
<div>
{items.map(key => (
<div key={key}>
{key}
</div>
))}
</div>
);
const a = Array.from({ length: 8 }).map((_, i) => `${i}`);
for (let i = 0; i < 10000; i++) {
const aa = randomize(a);
render(<App items={aa}/>, scratch);
expect(scratch.innerHTML).to.equal(
`<div>${aa.map(n => `<div>${n}</div>`).join('')}</div>`
);
}
});
Expected behavior |
@hzy Thank you so much for reporting these, added a log here for (let i = 0; i < 10000; i++) {
const aa = randomize(a);
console.log(aa)
render(<App items={aa}/>, scratch);
expect(scratch.innerHTML).to.equal(
`<div>${aa.map(n => `<div>${n}</div>`).join('')}</div>`
);
} To find the exact sequence that makes it fail and made #4472 to fix it. Thank you for bearing with me to find this fix. In the future you would be better off creating a new issue, I came across this by accident 😅 closed issues are often unsubscribed from |
Describe the bug
With preact version from 10.16.0 to 10.22.0, and code below:
Updating array
items
(shuffle it) leads to unexpected ordering.preact version 10.15.0 and below will not reproduce this issue.
To Reproduce (with Stackblitz)
Steps to reproduce the behavior:
Expected behavior
Numbers should be in order:
To Reproduce (in preact unit test)
test/browser/render.test.js
,Expected behavior
Test should pass.
The text was updated successfully, but these errors were encountered: