Skip to content

Commit 15bdb91

Browse files
committed
add deferred_tasks array
1 parent ddb0bc3 commit 15bdb91

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/svelte/src/internal/client/runtime.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ export function set_current_component_context(context) {
133133
current_component_context = context;
134134
}
135135

136+
/** @type {Function[]} */
137+
export let deferred_tasks = [];
138+
139+
/** @param {Function} task */
140+
export function defer(task) {
141+
deferred_tasks.push(task);
142+
}
143+
136144
/**
137145
* The current component function. Different from current component context:
138146
* ```html
@@ -561,7 +569,7 @@ function infinite_loop_guard() {
561569
* @returns {void}
562570
*/
563571
function flush_queued_root_effects(root_effects) {
564-
const length = root_effects.length;
572+
var length = root_effects.length;
565573
if (length === 0) {
566574
return;
567575
}
@@ -585,6 +593,10 @@ function flush_queued_root_effects(root_effects) {
585593
flush_queued_effects(collected_effects);
586594
}
587595
}
596+
597+
for (i = 0; i < deferred_tasks.length; i++) {
598+
deferred_tasks[i]();
599+
}
588600
} finally {
589601
is_flushing_effect = previously_flushing_effect;
590602
}

0 commit comments

Comments
 (0)