File tree Expand file tree Collapse file tree 5 files changed +130
-1
lines changed
store-invalidation-while-update-1
store-invalidation-while-update-2 Expand file tree Collapse file tree 5 files changed +130
-1
lines changed Original file line number Diff line number Diff line change @@ -73,8 +73,9 @@ function update($$) {
73
73
if ( $$ . fragment !== null ) {
74
74
$$ . update ( ) ;
75
75
run_all ( $$ . before_update ) ;
76
- $$ . fragment && $$ . fragment . p ( $$ . ctx , $$ . dirty ) ;
76
+ const dirty = $$ . dirty ;
77
77
$$ . dirty = [ - 1 ] ;
78
+ $$ . fragment && $$ . fragment . p ( $$ . ctx , dirty ) ;
78
79
79
80
$$ . after_update . forEach ( add_render_callback ) ;
80
81
}
Original file line number Diff line number Diff line change
1
+ export default {
2
+ html : `
3
+ <input>
4
+ <div></div>
5
+ <div>simple</div>
6
+ <button>click me</button>
7
+ ` ,
8
+
9
+ async test ( { assert, component, target, window } ) {
10
+ const input = target . querySelector ( 'input' ) ;
11
+ const button = target . querySelector ( 'button' ) ;
12
+
13
+ const inputEvent = new window . InputEvent ( 'input' ) ;
14
+ const clickEvent = new window . MouseEvent ( 'click' ) ;
15
+
16
+ input . value = 'foo' ;
17
+ await input . dispatchEvent ( inputEvent ) ;
18
+
19
+ assert . htmlEqual ( target . innerHTML , `
20
+ <input>
21
+ <div>foo</div>
22
+ <div>foo</div>
23
+ <button>click me</button>
24
+ ` ) ;
25
+
26
+ await button . dispatchEvent ( clickEvent ) ;
27
+ assert . htmlEqual ( target . innerHTML , `
28
+ <input>
29
+ <div>foo</div>
30
+ <div>clicked</div>
31
+ <button>click me</button>
32
+ ` ) ;
33
+
34
+ input . value = 'bar' ;
35
+ await input . dispatchEvent ( inputEvent ) ;
36
+
37
+ assert . htmlEqual ( target . innerHTML , `
38
+ <input>
39
+ <div>bar</div>
40
+ <div>bar</div>
41
+ <button>click me</button>
42
+ ` ) ;
43
+ }
44
+ } ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import {writable } from ' svelte/store' ;
3
+
4
+ function action (node , binding ) {
5
+ return {
6
+ update : (value ) => s .set (value),
7
+ }
8
+ }
9
+ let s = writable (" simple" );
10
+ let v = " " ;
11
+
12
+ function click () {
13
+ s .set (' clicked' );
14
+ }
15
+ </script >
16
+
17
+ <input bind:value ={v } use:action ={v }>
18
+ <div >{v }</div >
19
+ <div >{$s }</div >
20
+ <button on:click ={click }>click me</button >
Original file line number Diff line number Diff line change
1
+ export default {
2
+ html : `
3
+ <div></div>
4
+ <div>simple</div>
5
+ <input>
6
+ <button>click me</button>
7
+ ` ,
8
+
9
+ async test ( { assert, component, target, window } ) {
10
+ const input = target . querySelector ( 'input' ) ;
11
+ const button = target . querySelector ( 'button' ) ;
12
+
13
+ const inputEvent = new window . InputEvent ( 'input' ) ;
14
+ const clickEvent = new window . MouseEvent ( 'click' ) ;
15
+
16
+ input . value = 'foo' ;
17
+ await input . dispatchEvent ( inputEvent ) ;
18
+
19
+ assert . htmlEqual ( target . innerHTML , `
20
+ <div>foo</div>
21
+ <div>foo</div>
22
+ <input>
23
+ <button>click me</button>
24
+ ` ) ;
25
+
26
+ await button . dispatchEvent ( clickEvent ) ;
27
+ assert . htmlEqual ( target . innerHTML , `
28
+ <div>foo</div>
29
+ <div>clicked</div>
30
+ <input>
31
+ <button>click me</button>
32
+ ` ) ;
33
+
34
+ input . value = 'bar' ;
35
+ await input . dispatchEvent ( inputEvent ) ;
36
+
37
+ assert . htmlEqual ( target . innerHTML , `
38
+ <div>bar</div>
39
+ <div>bar</div>
40
+ <input>
41
+ <button>click me</button>
42
+ ` ) ;
43
+ }
44
+ } ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import {writable } from ' svelte/store' ;
3
+
4
+ function action (node , binding ) {
5
+ return {
6
+ update : (value ) => s .set (value),
7
+ }
8
+ }
9
+ let s = writable (" simple" );
10
+ let v = " " ;
11
+
12
+ function click () {
13
+ s .set (' clicked' );
14
+ }
15
+ </script >
16
+
17
+ <div >{v }</div >
18
+ <div >{$s }</div >
19
+ <input bind:value ={v } use:action ={v }>
20
+ <button on:click ={click }>click me</button >
You can’t perform that action at this time.
0 commit comments