mirror of https://github.com/sveltejs/svelte
fix: destroy effect on error (#12376)
fixes #12360 --------- Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>pull/12385/head
parent
145d67a489
commit
47a073e0db
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: destroy effects that error on creation
|
@ -0,0 +1,13 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: '<p><p>invalid</p></p>',
|
||||
mode: ['hydrate'],
|
||||
recover: true,
|
||||
test({ assert, target, logs }) {
|
||||
target.click();
|
||||
flushSync();
|
||||
assert.deepEqual(logs, ['body', 'document', 'window']);
|
||||
}
|
||||
});
|
@ -0,0 +1,5 @@
|
||||
<svelte:window onclick={() => console.log('window')} />
|
||||
<svelte:document onclick={() => console.log('document')} />
|
||||
<svelte:body onclick={() => console.log('body')} />
|
||||
|
||||
<p>{@html '<p>invalid</p>'}</p>
|
@ -0,0 +1,3 @@
|
||||
<script>
|
||||
throw new Error('boom');
|
||||
</script>
|
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
import Inner from './Inner.svelte';
|
||||
</script>
|
||||
|
||||
<svelte:window onclick={() => console.log('window')} />
|
||||
<svelte:document onclick={() => console.log('document')} />
|
||||
<svelte:body onclick={() => console.log('body')} />
|
||||
|
||||
<Inner />
|
@ -0,0 +1,11 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['client'],
|
||||
test({ assert, target, logs }) {
|
||||
target.click();
|
||||
flushSync();
|
||||
assert.deepEqual(logs, []);
|
||||
}
|
||||
});
|
@ -0,0 +1,14 @@
|
||||
<script>
|
||||
import { mount, onMount } from 'svelte';
|
||||
import Outer from './Outer.svelte';
|
||||
|
||||
let el;
|
||||
|
||||
onMount(() => {
|
||||
try {
|
||||
mount(Outer, { target: el });
|
||||
} catch {}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div bind:this={el}></div>
|
Loading…
Reference in new issue