mirror of https://github.com/sveltejs/svelte
parent
cd3a11edff
commit
bd697c12c6
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: flush pending changes after rendering `failed` snippet
|
||||
@ -0,0 +1,12 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target, logs }) {
|
||||
const btn = target.querySelector('button');
|
||||
btn?.click();
|
||||
await tick();
|
||||
|
||||
assert.deepEqual(logs, ['attachment']);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,20 @@
|
||||
<script>
|
||||
let fail = $state(false);
|
||||
|
||||
function error() {
|
||||
throw new Error('oops');
|
||||
}
|
||||
|
||||
function attachment() {
|
||||
console.log('attachment');
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:boundary>
|
||||
{fail ? error() : 'all good'}
|
||||
<button onclick={() => fail = true}>fail</button>
|
||||
|
||||
{#snippet failed()}
|
||||
<div {@attach attachment}>oops!</div>
|
||||
{/snippet}
|
||||
</svelte:boundary>
|
||||
Loading…
Reference in new issue