pull/16197/head
Rich Harris 9 months ago
parent 8aaa5688e4
commit 0e4f041ae2

@ -95,10 +95,7 @@ export class Fork {
*/
run(fn) {
active_fork = this;
flush_sync(fn);
active_fork = null;
}
increment() {
@ -121,8 +118,4 @@ export class Fork {
return active_fork;
}
static unset() {
active_fork = null;
}
}

@ -686,6 +686,12 @@ function infinite_loop_guard() {
* @returns {void}
*/
function flush_queued_root_effects(root_effects) {
if (active_fork === null) {
return;
}
var revert = active_fork.apply();
var length = root_effects.length;
if (length === 0) {
return;
@ -695,9 +701,6 @@ function flush_queued_root_effects(root_effects) {
var previously_flushing_effect = is_flushing_effect;
is_flushing_effect = true;
var fork = /** @type {Fork} */ (active_fork);
var revert = fork.apply();
try {
for (var i = 0; i < length; i++) {
var effect = root_effects[i];
@ -708,7 +711,7 @@ function flush_queued_root_effects(root_effects) {
var collected_effects = process_effects(effect);
if (fork.settled()) {
if (active_fork.settled()) {
flush_queued_effects(collected_effects);
}
}
@ -718,8 +721,8 @@ function flush_queued_root_effects(root_effects) {
// TODO this doesn't seem quite right — may run into
// interesting cases where there are multiple roots.
// it'll do for now though
if (fork.settled()) {
fork.remove();
if (active_fork.settled()) {
active_fork.remove();
}
revert();
@ -903,11 +906,8 @@ export function flush_sync(fn) {
try {
infinite_loop_guard();
/** @type {Effect[]} */
const root_effects = [];
scheduler_mode = FLUSH_SYNC;
queued_root_effects = root_effects;
queued_root_effects = [];
is_micro_task_queued = false;
flush_queued_root_effects(previous_queued_root_effects);
@ -917,7 +917,7 @@ export function flush_sync(fn) {
flush_boundary_micro_tasks();
flush_post_micro_tasks();
flush_idle_tasks();
if (queued_root_effects.length > 0 || root_effects.length > 0) {
if (queued_root_effects.length > 0) {
flush_sync();
}

Loading…
Cancel
Save