File tree Expand file tree Collapse file tree 2 files changed +7
-38
lines changed
Expand file tree Collapse file tree 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' ;
22import { get_current_component , set_current_component } from './lifecycle' ;
33
4- export const dirty_components = new Queue < any > ( ) ;
4+ export const dirty_components = [ ] ;
55export const intros = { enabled : false } ;
66
77export const binding_callbacks = [ ] ;
@@ -32,6 +32,7 @@ export function add_flush_callback(fn) {
3232}
3333
3434const seen_callbacks = new Set ( ) ;
35+ let flushidx = 0 ; // Do *not* move this inside the flush() function
3536export function flush ( ) {
3637
3738 let current_component = null ;
@@ -44,14 +45,16 @@ export function flush() {
4445 do {
4546 // first, call beforeUpdate functions
4647 // 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 ++ ;
4951 set_current_component ( component ) ;
5052 update ( component . $$ ) ;
5153 }
5254 set_current_component ( null ) ;
5355
5456 dirty_components . length = 0 ;
57+ flushidx = 0 ;
5558
5659 while ( binding_callbacks . length ) binding_callbacks . pop ( ) ( ) ;
5760
Original file line number Diff line number Diff line change @@ -58,40 +58,6 @@ export function is_empty(obj) {
5858 return Object . keys ( obj ) . length === 0 ;
5959}
6060
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-
9561export function validate_store ( store , name ) {
9662 if ( store != null && typeof store . subscribe !== 'function' ) {
9763 throw new Error ( `'${ name } ' is not a store with a 'subscribe' method` ) ;
You can’t perform that action at this time.
0 commit comments