mirror of https://github.com/sveltejs/svelte
fix: improve state store mutation compiler output (#10561)
parent
5698fb789c
commit
0afb8d489e
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: improve state store mutation compiler output
|
@ -0,0 +1,14 @@
|
||||
<script>
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
let { data } = $props();
|
||||
let form = writable(data.form);
|
||||
|
||||
function addTag() {
|
||||
$form.data.tags['third'] = 3;
|
||||
}
|
||||
</script>
|
||||
|
||||
<pre>{JSON.stringify($form, null, 2)}</pre>
|
||||
|
||||
<button on:click={addTag}>add</button>
|
@ -0,0 +1,17 @@
|
||||
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,
|
||||
`<pre>{\n"data": { "tags": { "first": 1, "second": 2, "third": 3 } } }</pre><button>add</button>`
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
<script>
|
||||
import Page from './Component.svelte';
|
||||
|
||||
let data = $state({ form: { data: { tags: { first: 1, second: 2 }}}});
|
||||
</script>
|
||||
<Page {data} />
|
Loading…
Reference in new issue