mirror of https://github.com/sveltejs/svelte
fix: prevent infinite loop when writing to store using shorthand (#10477)
Fixes #10472 This PR ensures we untrack parts of the compiled output to a store write, such as that this no longer brings up an infinite updates errorpull/10487/head
parent
87d4b12620
commit
cc273f7d53
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: prevent infinite loop when writing to store using shorthand
|
@ -0,0 +1,26 @@
|
||||
import { flushSync } from '../../../../src/main/main-client';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
flushSync(() => {
|
||||
btn?.click();
|
||||
});
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<p>test_store:\n 4</p><p>counter:\n 4</p><button>+1</button>`
|
||||
);
|
||||
|
||||
flushSync(() => {
|
||||
btn?.click();
|
||||
});
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<p>test_store:\n 5</p><p>counter:\n 5</p><button>+1</button>`
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
let test_store = writable({id:0});
|
||||
let counter = $state(3);
|
||||
|
||||
$effect(() => {
|
||||
$test_store.id = counter
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<p>test_store: {$test_store.id}</p>
|
||||
<p>counter: {counter}</p>
|
||||
|
||||
<button onclick={() => counter++}>+1</button>
|
Loading…
Reference in new issue