mirror of https://github.com/sveltejs/svelte
fix: improve indexed each equality (#10702)
parent
4285e6d814
commit
d9d1022895
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: improve indexed each equality
|
@ -0,0 +1,21 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `1\n1\n<button>+</button>`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
/**
|
||||
* @type {{ click: () => void; }}
|
||||
*/
|
||||
let btn1;
|
||||
|
||||
[btn1] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => {
|
||||
btn1.click();
|
||||
});
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `2\n2\n<button>+</button>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,20 @@
|
||||
<script>
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
let store = writable([{ value: 1 }]);
|
||||
let storeDeeper = writable({ items: [{ value: 1 }] });
|
||||
|
||||
function increment() {
|
||||
$store[0].value++;
|
||||
$storeDeeper.items[0].value++;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#each $store as item}
|
||||
{item.value}
|
||||
{/each}
|
||||
{#each $storeDeeper.items as item}
|
||||
{item.value}
|
||||
{/each}
|
||||
|
||||
<button onclick={increment}>+</button>
|
Loading…
Reference in new issue