mirror of https://github.com/sveltejs/svelte
fix: Don't destroy boundary contents on error unless the boundary is an error boundary (#16746)
* fix: Don't destroy contents of boundaries on errors if they're not error boundaries * changeset * test * prettier * prettier * simplify test * oops --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/16744/head
parent
68d27f1c4f
commit
f09f25e6a3
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: don't destroy contents of `svelte:boundary` unless the boundary is an error boundary
|
@ -0,0 +1,20 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
import { flushSync } from 'svelte';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
test({ assert, target }) {
|
||||||
|
const [button] = target.querySelectorAll('button');
|
||||||
|
|
||||||
|
assert.throws(() => {
|
||||||
|
flushSync(() => button.click());
|
||||||
|
}, /oops/);
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>throw</button>
|
||||||
|
<p>some content</p>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,19 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
let should_throw = $state(false);
|
||||||
|
|
||||||
|
function throw_error() {
|
||||||
|
throw new Error('oops');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => should_throw = true}>
|
||||||
|
throw
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<svelte:boundary>
|
||||||
|
<p>some content</p>
|
||||||
|
|
||||||
|
{#if should_throw}
|
||||||
|
{throw_error()}
|
||||||
|
{/if}
|
||||||
|
</svelte:boundary>
|
Loading…
Reference in new issue