Skip to content

Commit fb77e28

Browse files
committed
use queue_micro_task
1 parent 15bdb91 commit fb77e28

File tree

4 files changed

+6
-17
lines changed

4 files changed

+6
-17
lines changed

packages/svelte/src/internal/client/dom/elements/bindings/input.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { stringify } from '../../../render.js';
44
import { listen_to_event_and_reset_event } from './shared.js';
55
import * as e from '../../../errors.js';
66
import { get_proxied_value, is } from '../../../proxy.js';
7+
import { queue_micro_task } from '../../task.js';
78

89
/**
910
* @param {HTMLInputElement} input
@@ -111,7 +112,7 @@ export function bind_group(inputs, group_index, input, get_value, update) {
111112
}
112113
});
113114

114-
effect(() => {
115+
queue_micro_task(() => {
115116
// necessary to maintain binding group order in all insertion scenarios. TODO optimise
116117
binding_group.sort((a, b) => (a.compareDocumentPosition(b) === 4 ? -1 : 1));
117118
});

packages/svelte/src/internal/client/dom/elements/misc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { hydrating } from '../hydration.js';
2-
import { effect } from '../../reactivity/effects.js';
32
import { clear_text_content } from '../operations.js';
3+
import { queue_micro_task } from '../task.js';
44

55
/**
66
* @param {HTMLElement} dom
@@ -12,7 +12,7 @@ export function autofocus(dom, value) {
1212
const body = document.body;
1313
dom.autofocus = true;
1414

15-
effect(() => {
15+
queue_micro_task(() => {
1616
if (document.activeElement === body) {
1717
dom.focus();
1818
}

packages/svelte/src/internal/client/dom/template.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { empty } from './operations.js';
33
import { create_fragment_from_html } from './reconciler.js';
44
import { current_effect } from '../runtime.js';
55
import { TEMPLATE_FRAGMENT, TEMPLATE_USE_IMPORT_NODE } from '../../../constants.js';
6-
import { effect } from '../reactivity/effects.js';
76
import { is_array } from '../utils.js';
7+
import { queue_micro_task } from './task.js';
88

99
/**
1010
* @template {import("#client").TemplateNode | import("#client").TemplateNode[]} T
@@ -196,7 +196,7 @@ function run_scripts(node) {
196196
// Don't do it in other circumstances or we could accidentally execute scripts
197197
// in an adjacent @html tag that was instantiated in the meantime.
198198
if (script === node) {
199-
effect(() => script.replaceWith(clone));
199+
queue_micro_task(() => script.replaceWith(clone));
200200
} else {
201201
script.replaceWith(clone);
202202
}

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,6 @@ 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-
144136
/**
145137
* The current component function. Different from current component context:
146138
* ```html
@@ -593,10 +585,6 @@ function flush_queued_root_effects(root_effects) {
593585
flush_queued_effects(collected_effects);
594586
}
595587
}
596-
597-
for (i = 0; i < deferred_tasks.length; i++) {
598-
deferred_tasks[i]();
599-
}
600588
} finally {
601589
is_flushing_effect = previously_flushing_effect;
602590
}

0 commit comments

Comments
 (0)