mirror of https://github.com/sveltejs/svelte
fix: keep effect in the graph if it has an abort controller (#16430)
parent
93a8a495d2
commit
c2da1ebb85
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: keep effect in the graph if it has an abort controller
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
import { getAbortSignal } from 'svelte';
|
||||
|
||||
$effect(() => {
|
||||
const signal = getAbortSignal()
|
||||
signal.addEventListener('abort', () => console.log('abort'))
|
||||
})
|
||||
</script>
|
@ -0,0 +1,12 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target, logs }) {
|
||||
const btn = target.querySelector('button');
|
||||
flushSync(() => {
|
||||
btn?.click();
|
||||
});
|
||||
assert.deepEqual(logs, ['abort']);
|
||||
}
|
||||
});
|
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
import Component from './Component.svelte'
|
||||
|
||||
let show = $state(true)
|
||||
</script>
|
||||
|
||||
<button onclick={() => (show = !show)}>click</button>
|
||||
{#if show}
|
||||
<Component />
|
||||
{/if}
|
Loading…
Reference in new issue