Skip to content

Commit e005bd7

Browse files
committed
Get unit tests working again
1 parent 50cc07e commit e005bd7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/runtime/internal/scheduler.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { run_all, Queue } from './utils';
2-
import { set_current_component } from './lifecycle';
2+
import { get_current_component, set_current_component } from './lifecycle';
33

44
export const dirty_components = new Queue<any>();
55
export const intros = { enabled: false };
@@ -34,6 +34,11 @@ export function add_flush_callback(fn) {
3434
const seen_callbacks = new Set();
3535
export function flush() {
3636

37+
let current_component = null;
38+
try {
39+
current_component = get_current_component()
40+
} catch {}
41+
3742
do {
3843
// first, call beforeUpdate functions
3944
// and update components
@@ -65,6 +70,8 @@ export function flush() {
6570
render_callbacks.length = 0;
6671
} while (dirty_components.length);
6772

73+
set_current_component(current_component);
74+
6875
while (flush_callbacks.length) {
6976
flush_callbacks.pop()();
7077
}

0 commit comments

Comments
 (0)