File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -31,18 +31,23 @@ export function add_flush_callback(fn) {
31
31
flush_callbacks . push ( fn ) ;
32
32
}
33
33
34
+ let flushing = false ;
34
35
const seen_callbacks = new Set ( ) ;
35
36
export function flush ( ) {
37
+ if ( flushing ) return ;
38
+ flushing = true ;
36
39
37
40
do {
38
41
// first, call beforeUpdate functions
39
42
// and update components
40
- while ( dirty_components . length ) {
41
- const component = dirty_components . shift ( ) ;
43
+ for ( let i = 0 ; i < dirty_components . length ; i += 1 ) {
44
+ const component = dirty_components [ i ] ;
42
45
set_current_component ( component ) ;
43
46
update ( component . $$ ) ;
44
47
}
45
48
49
+ dirty_components . length = 0 ;
50
+
46
51
while ( binding_callbacks . length ) binding_callbacks . pop ( ) ( ) ;
47
52
48
53
// then, once components are updated, call
@@ -67,6 +72,7 @@ export function flush() {
67
72
}
68
73
69
74
update_scheduled = false ;
75
+ flushing = false ;
70
76
seen_callbacks . clear ( ) ;
71
77
}
72
78
You can’t perform that action at this time.
0 commit comments