mirror of https://github.com/sveltejs/svelte
fix: improve member expression mutation logic (#9625)
* fix: improve member expression mutation logic * cleanup * Update .changeset/moody-frogs-exist.md --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>pull/9607/head
parent
7825570b07
commit
ef68b66dee
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: improve member expression mutation logic
|
@ -0,0 +1,19 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `<button>person.name.first = "dave"</button><h3>JSON output</h3><div>[{"name":{"first":"rob"}}]</div>`,
|
||||||
|
|
||||||
|
async test({ assert, target }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
|
||||||
|
flushSync(() => {
|
||||||
|
button?.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`<button>person.name.first = "dave"</button><h3>JSON output</h3><div>[{"name":{"first":"dave"}}]</div>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,15 @@
|
|||||||
|
<script>
|
||||||
|
let people = $state([{name:{first:'rob'}}]);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each people as person}
|
||||||
|
<button on:click={()=>{
|
||||||
|
person.name.first = "dave";
|
||||||
|
people = people;
|
||||||
|
}}>person.name.first = "dave"</button>
|
||||||
|
{/each}
|
||||||
|
|
||||||
|
<h3>JSON output</h3>
|
||||||
|
{#each people as person}
|
||||||
|
<div>{JSON.stringify(people)}</div>
|
||||||
|
{/each}
|
Loading…
Reference in new issue