File tree Expand file tree Collapse file tree 2 files changed +45
-10
lines changed
packages/svelte/tests/runtime-legacy/samples/reactive-value-assign-properties Expand file tree Collapse file tree 2 files changed +45
-10
lines changed Original file line number Diff line number Diff line change 1+ import { flushSync } from 'svelte' ;
12import { test } from '../../test' ;
23
34export default test ( {
4- html : `1 1`
5+ html : `<button>false</button><button>false</button><button>false</button><button>false</button>` ,
6+ test ( { assert, target } ) {
7+ const [ button1 , button2 , button3 , button4 ] = target . querySelectorAll ( 'button' ) ;
8+
9+ button1 . click ( ) ;
10+ flushSync ( ) ;
11+ assert . htmlEqual (
12+ target . innerHTML ,
13+ `<button>true</button><button>false</button><button>false</button><button>false</button>`
14+ ) ;
15+
16+ button2 . click ( ) ;
17+ flushSync ( ) ;
18+ assert . htmlEqual (
19+ target . innerHTML ,
20+ `<button>true</button><button>true</button><button>false</button><button>false</button>`
21+ ) ;
22+
23+ button3 . click ( ) ;
24+ flushSync ( ) ;
25+ assert . htmlEqual (
26+ target . innerHTML ,
27+ `<button>true</button><button>true</button><button>true</button><button>false</button>`
28+ ) ;
29+
30+ button4 . click ( ) ;
31+ flushSync ( ) ;
32+ assert . htmlEqual (
33+ target . innerHTML ,
34+ `<button>true</button><button>true</button><button>true</button><button>true</button>`
35+ ) ;
36+ }
537} ) ;
Original file line number Diff line number Diff line change 11<script >
2- let button = { title: ' ' , label: ' ' };
3- let title = ' ' ;
4- let label = ' ' ;
5-
6- title = label = ' 1' ; // to add dependencies/generate update block
7-
8- $: button .title = title;
9- $: button .label = label;
2+ let array;
3+ $: {
4+ // test that this doesn't rerun on array change
5+ array = []
6+ array[0 ] = [false , false ];
7+ array[1 ] = [false , false ];
8+ }
109 </script >
1110
12- {button .title } {button .label }
11+ {#each array as row , i }
12+ {#each row as item , j }
13+ <button on:click ={() => array [i ][j ] = ! array [i ][j ]}>{item }</button >
14+ {/each }
15+ {/each }
You can’t perform that action at this time.
0 commit comments