mirror of https://github.com/sveltejs/svelte
fix: catch error on @const tag in svelte:boundary in DEV mode (#15369)
* fix: catch error on @const tag in svelte:boundary * changeset * edit changeset * test * fix * rollback * simpler way to do that * rollback * roolback again --------- Co-authored-by: paoloricciuti <ricciutipaolo@gmail.com>pull/15383/head
parent
be82332ac8
commit
fe343e9c50
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: catch error on @const tag in svelte:boundary in DEV mode
|
@ -0,0 +1,33 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
// https://github.com/sveltejs/svelte/issues/15368
|
||||||
|
export default test({
|
||||||
|
compileOptions: {
|
||||||
|
dev: true
|
||||||
|
},
|
||||||
|
|
||||||
|
mode: ['client'],
|
||||||
|
|
||||||
|
html: `
|
||||||
|
<p>BOOM</p>
|
||||||
|
<p>BOOM</p>
|
||||||
|
<div>OK</div>
|
||||||
|
<div>OK</div>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ target, assert, component }) {
|
||||||
|
component.ok = false;
|
||||||
|
flushSync();
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<p>BOOM</p>
|
||||||
|
<p>BOOM</p>
|
||||||
|
<p>BOOM</p>
|
||||||
|
<p>BOOM</p>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,49 @@
|
|||||||
|
<script>
|
||||||
|
let { ok = true } = $props();
|
||||||
|
|
||||||
|
function throwError() {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
|
|
||||||
|
function throwErrorOnUpdate() {
|
||||||
|
if (ok) {
|
||||||
|
return "OK";
|
||||||
|
} else {
|
||||||
|
throwError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:boundary>
|
||||||
|
<div>{throwError()}</div>
|
||||||
|
|
||||||
|
{#snippet failed()}
|
||||||
|
<p>BOOM</p>
|
||||||
|
{/snippet}
|
||||||
|
</svelte:boundary>
|
||||||
|
|
||||||
|
<svelte:boundary>
|
||||||
|
{@const result = throwError()}
|
||||||
|
<div>{result}</div>
|
||||||
|
|
||||||
|
{#snippet failed()}
|
||||||
|
<p>BOOM</p>
|
||||||
|
{/snippet}
|
||||||
|
</svelte:boundary>
|
||||||
|
|
||||||
|
<svelte:boundary>
|
||||||
|
<div>{throwErrorOnUpdate()}</div>
|
||||||
|
|
||||||
|
{#snippet failed()}
|
||||||
|
<p>BOOM</p>
|
||||||
|
{/snippet}
|
||||||
|
</svelte:boundary>
|
||||||
|
|
||||||
|
<svelte:boundary>
|
||||||
|
{@const result = throwErrorOnUpdate()}
|
||||||
|
<div>{result}</div>
|
||||||
|
|
||||||
|
{#snippet failed()}
|
||||||
|
<p>BOOM</p>
|
||||||
|
{/snippet}
|
||||||
|
</svelte:boundary>
|
Loading…
Reference in new issue