Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc2da1eb

Browse files
fix: keep effect in the graph if it has an abort controller (#16430)
1 parent93a8a49 commitc2da1eb

File tree

5 files changed

+38
-1
lines changed

5 files changed

+38
-1
lines changed

‎.changeset/four-kings-drum.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte':patch
3+
---
4+
5+
fix: keep effect in the graph if it has an abort controller

‎packages/svelte/src/internal/client/reactivity/batch.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,9 @@ function flush_queued_effects(effects) {
532532
// here (rather than in `update_effect`) allows us to skip the work for
533533
// immediate effects.
534534
if(effect.deps===null&&effect.first===null&&effect.nodes_start===null){
535-
if(effect.teardown===null){
535+
// if there's no teardown or abort controller we completely unlink
536+
// the effect from the graph
537+
if(effect.teardown===null&&effect.ac===null){
536538
// remove this effect from the graph
537539
unlink_effect(effect);
538540
}else{
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script>
2+
import {getAbortSignal }from'svelte';
3+
4+
$effect(()=> {
5+
constsignal=getAbortSignal()
6+
signal.addEventListener('abort', ()=>console.log('abort'))
7+
})
8+
</script>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import{flushSync}from'svelte';
2+
import{test}from'../../test';
3+
4+
exportdefaulttest({
5+
asynctest({ assert, target, logs}){
6+
constbtn=target.querySelector('button');
7+
flushSync(()=>{
8+
btn?.click();
9+
});
10+
assert.deepEqual(logs,['abort']);
11+
}
12+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>
2+
importComponentfrom'./Component.svelte'
3+
4+
let show=$state(true)
5+
</script>
6+
7+
<buttononclick={()=> (show=!show)}>click</button>
8+
{#ifshow}
9+
<Component />
10+
{/if}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp