File tree Expand file tree Collapse file tree 2 files changed +3
-33
lines changed
packages/svelte/src/internal/client/dom Expand file tree Collapse file tree 2 files changed +3
-33
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { create_event, delegate } from './events.js';
66import { add_form_reset_listener , autofocus } from './misc.js' ;
77import * as w from '../../warnings.js' ;
88import { LOADING_ATTR_SYMBOL } from '#client/constants' ;
9- import { queue_idle_task } from '../task.js' ;
9+ import { queue_micro_task } from '../task.js' ;
1010import { is_capture_event , is_delegated , normalize_attribute } from '../../../../utils.js' ;
1111import {
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
Original file line number Diff line number Diff line change 11import { run_all } from '../../shared/utils.js' ;
22import { 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> } */
115let micro_tasks = [ ] ;
126
13- /** @type {Array<() => void> } */
14- let idle_tasks = [ ] ;
15-
167function 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-
2813export 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 */
6842export 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}
You can’t perform that action at this time.
0 commit comments