mirror of https://github.com/sveltejs/svelte
parent
c05e94f26e
commit
f3265c580c
@ -1,5 +1,37 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
import { test } from '../../test';
|
import { test } from '../../test';
|
||||||
|
|
||||||
export default test({
|
export default test({
|
||||||
html: `1 1`
|
html: `<button>false</button><button>false</button><button>false</button><button>false</button>`,
|
||||||
|
test({ assert, target }) {
|
||||||
|
const [button1, button2, button3, button4] = target.querySelectorAll('button');
|
||||||
|
|
||||||
|
button1.click();
|
||||||
|
flushSync();
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`<button>true</button><button>false</button><button>false</button><button>false</button>`
|
||||||
|
);
|
||||||
|
|
||||||
|
button2.click();
|
||||||
|
flushSync();
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`<button>true</button><button>true</button><button>false</button><button>false</button>`
|
||||||
|
);
|
||||||
|
|
||||||
|
button3.click();
|
||||||
|
flushSync();
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`<button>true</button><button>true</button><button>true</button><button>false</button>`
|
||||||
|
);
|
||||||
|
|
||||||
|
button4.click();
|
||||||
|
flushSync();
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`<button>true</button><button>true</button><button>true</button><button>true</button>`
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
<script>
|
<script>
|
||||||
let button = { title: '', label: '' };
|
let array;
|
||||||
let title = '';
|
$: {
|
||||||
let label = '';
|
// test that this doesn't rerun on array change
|
||||||
|
array = []
|
||||||
title = label = '1'; // to add dependencies/generate update block
|
array[0] = [false, false];
|
||||||
|
array[1] = [false, false];
|
||||||
$: button.title = title;
|
}
|
||||||
$: button.label = label;
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{button.title} {button.label}
|
{#each array as row, i}
|
||||||
|
{#each row as item, j}
|
||||||
|
<button on:click={() => array[i][j] = !array[i][j]}>{item}</button>
|
||||||
|
{/each}
|
||||||
|
{/each}
|
||||||
|
Loading…
Reference in new issue