From e005bd7f03cbd773a106e7ee05d3c49d7a73bac4 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Wed, 17 Nov 2021 16:26:11 +0700 Subject: [PATCH] Get unit tests working again --- src/runtime/internal/scheduler.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/runtime/internal/scheduler.ts b/src/runtime/internal/scheduler.ts index cc93a6af53..1c8cfd9774 100644 --- a/src/runtime/internal/scheduler.ts +++ b/src/runtime/internal/scheduler.ts @@ -1,5 +1,5 @@ import { run_all, Queue } from './utils'; -import { set_current_component } from './lifecycle'; +import { get_current_component, set_current_component } from './lifecycle'; export const dirty_components = new Queue(); export const intros = { enabled: false }; @@ -34,6 +34,11 @@ export function add_flush_callback(fn) { const seen_callbacks = new Set(); export function flush() { + let current_component = null; + try { + current_component = get_current_component() + } catch {} + do { // first, call beforeUpdate functions // and update components @@ -65,6 +70,8 @@ export function flush() { render_callbacks.length = 0; } while (dirty_components.length); + set_current_component(current_component); + while (flush_callbacks.length) { flush_callbacks.pop()(); }