mirror of https://github.com/sveltejs/svelte
fix: ensure each block inert items are disposed of if the each block is also inert (#13930)
Fixes #13926pull/14064/head
parent
e47ee22628
commit
3999fed4ca
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure each block inert items are disposed of if the each block is also inert
|
@ -0,0 +1,31 @@
|
||||
import { flushSync } from '../../../../src/index-client.js';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, raf, target }) {
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
'<button>Toggle</button><div><div>1</div><div>2</div><div>3</div></div>'
|
||||
);
|
||||
|
||||
const btn1 = target.querySelector('button');
|
||||
btn1?.click();
|
||||
flushSync();
|
||||
raf.tick(250);
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
'<button>Toggle</button><div style="opacity: 0.5;"><div>1</div><div>2</div><div>3</div></div>'
|
||||
);
|
||||
|
||||
await Promise.resolve();
|
||||
|
||||
flushSync();
|
||||
raf.tick(500);
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
'<button>Toggle</button><div style=""><div>3</div><div>4</div></div>'
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,28 @@
|
||||
<script>
|
||||
function fade(_) {
|
||||
return {
|
||||
duration: 500,
|
||||
css: t => `opacity: ${t}`,
|
||||
}
|
||||
}
|
||||
|
||||
let toggle = $state(true);
|
||||
let items = $state([ 1, 2, 3 ]);
|
||||
|
||||
const handle_toggle = async () => {
|
||||
toggle = false;
|
||||
await Promise.resolve();
|
||||
items = [3, 4];
|
||||
toggle = true;
|
||||
};
|
||||
</script>
|
||||
|
||||
<button onclick={handle_toggle}>Toggle</button>
|
||||
|
||||
{#if toggle}
|
||||
<div transition:fade>
|
||||
{#each items as item (item)}
|
||||
<div>{item}</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
Loading…
Reference in new issue