mirror of https://github.com/sveltejs/svelte
fix: further improve reconciliation of inert each block rows (#13527)
Inert effects are currently outroing and will be removed once the transition is finished Fixes #13302pull/13497/head
parent
db305a07f2
commit
765ca030d6
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: further improve reconciliation of inert each block rows
|
@ -0,0 +1,34 @@
|
||||
import { flushSync } from '../../../../src/index-client.js';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, raf, target }) {
|
||||
const [btn1, btn2] = target.querySelectorAll('button');
|
||||
|
||||
btn1?.click();
|
||||
btn1?.click();
|
||||
btn1?.click();
|
||||
flushSync();
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
'<button>Push</button><button>Remove</button><ul><li>0</li><li>1</li><li>2</li></ul>'
|
||||
);
|
||||
|
||||
btn2?.click();
|
||||
flushSync();
|
||||
raf.tick(50);
|
||||
|
||||
const li = /** @type {HTMLElement & { foo: number }} */ (target.querySelector('ul > li'));
|
||||
|
||||
assert.equal(li.foo, 0.5);
|
||||
|
||||
btn1?.click();
|
||||
flushSync();
|
||||
|
||||
assert.equal(li.foo, 0.5);
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
'<button>Push</button><button>Remove</button><ul><li>3</li><li>0</li><li>1</li><li>2</li></ul>'
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,30 @@
|
||||
<script>
|
||||
function foo(node, params) {
|
||||
return {
|
||||
duration: 100,
|
||||
tick: (t, u) => {
|
||||
node.foo = t;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let list = $state([]);
|
||||
let id = 0;
|
||||
|
||||
function push() {
|
||||
list.push({ id: id++ })
|
||||
}
|
||||
|
||||
function remove() {
|
||||
list = [];
|
||||
}
|
||||
</script>
|
||||
|
||||
<button onclick={push}>Push</button>
|
||||
<button onclick={remove}>Remove</button>
|
||||
|
||||
<ul>
|
||||
{#each list as item (item.id)}
|
||||
<li out:foo>{item.id}</li>
|
||||
{/each}
|
||||
</ul>
|
Loading…
Reference in new issue