|
|
|
@ -32,71 +32,38 @@ export function add_flush_callback(fn) {
|
|
|
|
|
|
|
|
|
|
let flushing = false;
|
|
|
|
|
const seen_callbacks = new Set();
|
|
|
|
|
// export function flush() {
|
|
|
|
|
// if (flushing) return;
|
|
|
|
|
// flushing = true;
|
|
|
|
|
|
|
|
|
|
// do {
|
|
|
|
|
// // update components + beforeUpdate
|
|
|
|
|
// for (let i = 0, component; i < dirty_components.length; i++) {
|
|
|
|
|
// set_current_component((component = dirty_components[i]));
|
|
|
|
|
// update(component.$$);
|
|
|
|
|
// }
|
|
|
|
|
// dirty_components.length = 0;
|
|
|
|
|
|
|
|
|
|
// // update bindings
|
|
|
|
|
// for (let i = 0; i < binding_callbacks.length; i++) {
|
|
|
|
|
// binding_callbacks[i]();
|
|
|
|
|
// }
|
|
|
|
|
// binding_callbacks.length = 0;
|
|
|
|
|
|
|
|
|
|
// // afterUpdate
|
|
|
|
|
// for (let i = 0, callback; i < render_callbacks.length; i++) {
|
|
|
|
|
// if (seen_callbacks.has((callback = render_callbacks[i]))) continue;
|
|
|
|
|
// seen_callbacks.add(callback);
|
|
|
|
|
// callback();
|
|
|
|
|
// }
|
|
|
|
|
// render_callbacks.length = 0;
|
|
|
|
|
// } while (dirty_components.length);
|
|
|
|
|
|
|
|
|
|
// for (let i = 0; i < flush_callbacks.length; i++) {
|
|
|
|
|
// flush_callbacks[i]();
|
|
|
|
|
// }
|
|
|
|
|
// flush_callbacks.length = 0;
|
|
|
|
|
|
|
|
|
|
// update_scheduled = false;
|
|
|
|
|
// flushing = false;
|
|
|
|
|
// seen_callbacks.clear();
|
|
|
|
|
// }
|
|
|
|
|
export function flush() {
|
|
|
|
|
if (flushing) return;
|
|
|
|
|
flushing = true;
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
// first, call beforeUpdate functions
|
|
|
|
|
// and update components
|
|
|
|
|
for (let i = 0; i < dirty_components.length; i += 1) {
|
|
|
|
|
const component = dirty_components[i];
|
|
|
|
|
set_current_component(component);
|
|
|
|
|
// update components + beforeUpdate
|
|
|
|
|
for (let i = 0, component; i < dirty_components.length; i++) {
|
|
|
|
|
set_current_component((component = dirty_components[i]));
|
|
|
|
|
update(component.$$);
|
|
|
|
|
}
|
|
|
|
|
dirty_components.length = 0;
|
|
|
|
|
while (binding_callbacks.length) binding_callbacks.pop()();
|
|
|
|
|
// then, once components are updated, call
|
|
|
|
|
// afterUpdate functions. This may cause
|
|
|
|
|
// subsequent updates...
|
|
|
|
|
for (let i = 0; i < render_callbacks.length; i += 1) {
|
|
|
|
|
const callback = render_callbacks[i];
|
|
|
|
|
if (!seen_callbacks.has(callback)) {
|
|
|
|
|
// ...so guard against infinite loops
|
|
|
|
|
|
|
|
|
|
// update bindings
|
|
|
|
|
for (let i = 0; i < binding_callbacks.length; i++) {
|
|
|
|
|
binding_callbacks[i]();
|
|
|
|
|
}
|
|
|
|
|
binding_callbacks.length = 0;
|
|
|
|
|
|
|
|
|
|
// afterUpdate
|
|
|
|
|
for (let i = 0, callback; i < render_callbacks.length; i++) {
|
|
|
|
|
if (seen_callbacks.has((callback = render_callbacks[i]))) continue;
|
|
|
|
|
seen_callbacks.add(callback);
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
render_callbacks.length = 0;
|
|
|
|
|
} while (dirty_components.length);
|
|
|
|
|
while (flush_callbacks.length) {
|
|
|
|
|
flush_callbacks.pop()();
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < flush_callbacks.length; i++) {
|
|
|
|
|
flush_callbacks[i]();
|
|
|
|
|
}
|
|
|
|
|
flush_callbacks.length = 0;
|
|
|
|
|
|
|
|
|
|
update_scheduled = false;
|
|
|
|
|
flushing = false;
|
|
|
|
|
seen_callbacks.clear();
|
|
|
|
|