-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve signal consumer removal logic
- Loading branch information
Showing
4 changed files
with
97 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: improve signal consumer removal logic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/svelte/tests/runtime-runes/samples/effect-dependencies/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
async test({ assert, target }) { | ||
const [b1, b2] = target.querySelectorAll('button'); | ||
flushSync(() => { | ||
b1.click(); | ||
}); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
`<div><button>A</button><button>B</button></div><div>A</div>` | ||
); | ||
|
||
flushSync(() => { | ||
b2.click(); | ||
}); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
`<div><button>A</button><button>B</button></div><div>B\n12</div>` | ||
); | ||
|
||
flushSync(() => { | ||
b1.click(); | ||
}); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
`<div><button>A</button><button>B</button></div><div>A</div>` | ||
); | ||
|
||
flushSync(() => { | ||
b2.click(); | ||
}); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
`<div><button>A</button><button>B</button></div><div>B\n12</div>` | ||
); | ||
|
||
flushSync(() => { | ||
b1.click(); | ||
}); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
`<div><button>A</button><button>B</button></div><div>A</div>` | ||
); | ||
} | ||
}); |
31 changes: 31 additions & 0 deletions
31
packages/svelte/tests/runtime-runes/samples/effect-dependencies/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script context="module"> | ||
class Things { | ||
tab = $state('A'); | ||
data = $state([{no: 1}, {no: 2}]); | ||
list = $derived(this.filter()); | ||
filter() { | ||
this.tab; | ||
return this.data; | ||
} | ||
} | ||
const things = new Things(); | ||
</script> | ||
|
||
<div> | ||
<button onclick={() => things.tab = 'A'} >A</button> | ||
<button onclick={() => things.tab = 'B'} >B</button> | ||
</div> | ||
|
||
<div> | ||
{#if things.tab === 'A'} | ||
A | ||
{:else} | ||
B | ||
{#each things.list as item} | ||
{item.no} | ||
{/each} | ||
{/if} | ||
</div> |