mirror of https://github.com/sveltejs/svelte
Merge b88b4e8ef8
into 2344b4052e
commit
5a08bc7c94
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure obsolete batches are removed and its necessary dom changes committed
|
@ -0,0 +1,36 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, logs, target }) {
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<h1>a</h1>
|
||||
<button>a</button>
|
||||
<button>b</button>
|
||||
<button>c</button>
|
||||
<p>a</p>
|
||||
`
|
||||
);
|
||||
|
||||
const [a, b] = target.querySelectorAll('button');
|
||||
|
||||
b.click();
|
||||
await tick();
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<h1>c</h1>
|
||||
<button>a</button>
|
||||
<button>b</button>
|
||||
<button>c</button>
|
||||
<p>c</p>
|
||||
<p>b or c</p>
|
||||
`
|
||||
);
|
||||
|
||||
assert.deepEqual(logs, ['route a', 'route c']);
|
||||
}
|
||||
});
|
@ -0,0 +1,41 @@
|
||||
<script lang=ts>
|
||||
let route = $state('a');
|
||||
|
||||
function goto(r) {
|
||||
return Promise.resolve().then(async () => {
|
||||
route = r;
|
||||
await Promise.resolve();
|
||||
});
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
console.log('route ' + route);
|
||||
});
|
||||
</script>
|
||||
|
||||
<h1>{route}</h1>
|
||||
<button onclick={() => route = 'a'}>a</button>
|
||||
<button onclick={() => route = 'b'}>b</button>
|
||||
<button onclick={() => route = 'c'}>c</button>
|
||||
|
||||
<svelte:boundary>
|
||||
{#if route === 'a'}
|
||||
<p>a</p>
|
||||
{/if}
|
||||
|
||||
{#if route === 'b'}
|
||||
{await goto('c')}
|
||||
{/if}
|
||||
|
||||
{#if route === 'c'}
|
||||
<p>c</p>
|
||||
{/if}
|
||||
|
||||
{#if route === 'b' || route === 'c'}
|
||||
<p>b or c</p>
|
||||
{/if}
|
||||
|
||||
{#snippet pending()}
|
||||
<p>pending...</p>
|
||||
{/snippet}
|
||||
</svelte:boundary>
|
Loading…
Reference in new issue