Skip to content

Commit f0cede6

Browse files
authored
chore: replace queue_idle_task with queue_micro_task (#16844)
1 parent b92a559 commit f0cede6

File tree

2 files changed

+3
-33
lines changed

2 files changed

+3
-33
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { create_event, delegate } from './events.js';
66
import { add_form_reset_listener, autofocus } from './misc.js';
77
import * as w from '../../warnings.js';
88
import { LOADING_ATTR_SYMBOL } from '#client/constants';
9-
import { queue_idle_task } from '../task.js';
9+
import { queue_micro_task } from '../task.js';
1010
import { is_capture_event, is_delegated, normalize_attribute } from '../../../../utils.js';
1111
import {
1212
active_effect,
@@ -65,7 +65,7 @@ export function remove_input_defaults(input) {
6565

6666
// @ts-expect-error
6767
input.__on_r = remove_defaults;
68-
queue_idle_task(remove_defaults);
68+
queue_micro_task(remove_defaults);
6969
add_form_reset_listener();
7070
}
7171

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,17 @@
11
import { run_all } from '../../shared/utils.js';
22
import { is_flushing_sync } from '../reactivity/batch.js';
33

4-
// Fallback for when requestIdleCallback is not available
5-
const request_idle_callback =
6-
typeof requestIdleCallback === 'undefined'
7-
? (/** @type {() => void} */ cb) => setTimeout(cb, 1)
8-
: requestIdleCallback;
9-
104
/** @type {Array<() => void>} */
115
let micro_tasks = [];
126

13-
/** @type {Array<() => void>} */
14-
let idle_tasks = [];
15-
167
function run_micro_tasks() {
178
var tasks = micro_tasks;
189
micro_tasks = [];
1910
run_all(tasks);
2011
}
2112

22-
function run_idle_tasks() {
23-
var tasks = idle_tasks;
24-
idle_tasks = [];
25-
run_all(tasks);
26-
}
27-
2813
export function has_pending_tasks() {
29-
return micro_tasks.length > 0 || idle_tasks.length > 0;
14+
return micro_tasks.length > 0;
3015
}
3116

3217
/**
@@ -51,26 +36,11 @@ export function queue_micro_task(fn) {
5136
micro_tasks.push(fn);
5237
}
5338

54-
/**
55-
* @param {() => void} fn
56-
*/
57-
export function queue_idle_task(fn) {
58-
if (idle_tasks.length === 0) {
59-
request_idle_callback(run_idle_tasks);
60-
}
61-
62-
idle_tasks.push(fn);
63-
}
64-
6539
/**
6640
* Synchronously run any queued tasks.
6741
*/
6842
export function flush_tasks() {
6943
if (micro_tasks.length > 0) {
7044
run_micro_tasks();
7145
}
72-
73-
if (idle_tasks.length > 0) {
74-
run_idle_tasks();
75-
}
7646
}

0 commit comments

Comments
 (0)