mirror of https://github.com/sveltejs/svelte
fix: ensure toStore root effect is connected to correct parent effect (#15574)
* fix: ensure toStore root effect is connected to correct parent effect * prettier --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/15575/head
parent
ade66c6fea
commit
1f37c02f91
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure toStore root effect is connected to correct parent effect
|
@ -0,0 +1,16 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
let btn = target.querySelector('button');
|
||||
|
||||
btn?.click();
|
||||
flushSync();
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<div>Count 1!</div><div>Count from store 1!</div><button>Add 1</button>`
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
import { toStore } from "svelte/store";
|
||||
|
||||
let counter = $state(0);
|
||||
const count = toStore(() => counter, value => counter = value);
|
||||
</script>
|
||||
|
||||
<div>Count {counter}!</div>
|
||||
<div>Count from store {$count}!</div>
|
||||
|
||||
<button onclick={() => counter+=1}>Add 1</button>
|
Loading…
Reference in new issue