mirror of https://github.com/sveltejs/svelte
fix: improve each block fallback handling (#9914)
parent
3a4a09102c
commit
b1efd8c4cd
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: improve each block fallback handling
|
@ -0,0 +1,17 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target, component }) {
|
||||
const [b1] = target.querySelectorAll('button');
|
||||
assert.htmlEqual(target.innerHTML, '<div>abc</div><button>Toggle</button>');
|
||||
flushSync(() => {
|
||||
b1.click();
|
||||
});
|
||||
assert.htmlEqual(target.innerHTML, '<div>Fallback</div><button>Toggle</button>');
|
||||
flushSync(() => {
|
||||
b1.click();
|
||||
});
|
||||
assert.htmlEqual(target.innerHTML, '<div>abc</div><button>Toggle</button>');
|
||||
}
|
||||
});
|
@ -0,0 +1,22 @@
|
||||
<script>
|
||||
let data = $state({a:1, b:2, c:3});
|
||||
let filter = $state(false);
|
||||
|
||||
function toggle_filter(){
|
||||
if(filter) {
|
||||
filter = false;
|
||||
data = {a:1, b:2, c:3};
|
||||
} else {
|
||||
filter = true;
|
||||
data = {};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div>
|
||||
{#each Object.keys(data) as key}
|
||||
{key}
|
||||
{:else}
|
||||
Fallback
|
||||
{/each}
|
||||
</div>
|
||||
<button onclick={toggle_filter}>Toggle</button>
|
Loading…
Reference in new issue