File tree 2 files changed +7
-38
lines changed 2 files changed +7
-38
lines changed Original file line number Diff line number Diff line change 1
- import { run_all , Queue } from './utils' ;
1
+ import { run_all } from './utils' ;
2
2
import { get_current_component , set_current_component } from './lifecycle' ;
3
3
4
- export const dirty_components = new Queue < any > ( ) ;
4
+ export const dirty_components = [ ] ;
5
5
export const intros = { enabled : false } ;
6
6
7
7
export const binding_callbacks = [ ] ;
@@ -32,6 +32,7 @@ export function add_flush_callback(fn) {
32
32
}
33
33
34
34
const seen_callbacks = new Set ( ) ;
35
+ let flushidx = 0 ; // Do *not* move this inside the flush() function
35
36
export function flush ( ) {
36
37
37
38
let current_component = null ;
@@ -44,14 +45,16 @@ export function flush() {
44
45
do {
45
46
// first, call beforeUpdate functions
46
47
// and update components
47
- while ( dirty_components . length ) {
48
- const component = dirty_components . shift ( ) ;
48
+ while ( flushidx < dirty_components . length ) {
49
+ const component = dirty_components [ flushidx ] ;
50
+ flushidx ++ ;
49
51
set_current_component ( component ) ;
50
52
update ( component . $$ ) ;
51
53
}
52
54
set_current_component ( null ) ;
53
55
54
56
dirty_components . length = 0 ;
57
+ flushidx = 0 ;
55
58
56
59
while ( binding_callbacks . length ) binding_callbacks . pop ( ) ( ) ;
57
60
Original file line number Diff line number Diff line change @@ -58,40 +58,6 @@ export function is_empty(obj) {
58
58
return Object . keys ( obj ) . length === 0 ;
59
59
}
60
60
61
- export class Queue < T > {
62
- forward : T [ ] ;
63
- reverse : T [ ] ;
64
-
65
- constructor ( ) {
66
- this . forward = [ ] ;
67
- this . reverse = [ ] ;
68
- }
69
- push ( value : T ) {
70
- return this . forward . push ( value ) ;
71
- }
72
- shift ( ) {
73
- if ( this . reverse . length === 0 ) {
74
- while ( this . forward . length ) {
75
- this . reverse . push ( this . forward . pop ( ) ) ;
76
- }
77
- }
78
- return this . reverse . pop ( ) ;
79
- }
80
- get length ( ) {
81
- return this . forward . length + this . reverse . length ;
82
- }
83
- set length ( len : number ) {
84
- if ( len === 0 ) {
85
- this . forward . length = 0 ;
86
- this . reverse . length = 0 ;
87
- } else {
88
- while ( this . length > len ) {
89
- this . shift ( ) ;
90
- }
91
- }
92
- }
93
- }
94
-
95
61
export function validate_store ( store , name ) {
96
62
if ( store != null && typeof store . subscribe !== 'function' ) {
97
63
throw new Error ( `'${ name } ' is not a store with a 'subscribe' method` ) ;
You can’t perform that action at this time.
0 commit comments