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';
6
6
import { add_form_reset_listener , autofocus } from './misc.js' ;
7
7
import * as w from '../../warnings.js' ;
8
8
import { LOADING_ATTR_SYMBOL } from '#client/constants' ;
9
- import { queue_idle_task } from '../task.js' ;
9
+ import { queue_micro_task } from '../task.js' ;
10
10
import { is_capture_event , is_delegated , normalize_attribute } from '../../../../utils.js' ;
11
11
import {
12
12
active_effect ,
@@ -65,7 +65,7 @@ export function remove_input_defaults(input) {
65
65
66
66
// @ts -expect-error
67
67
input . __on_r = remove_defaults ;
68
- queue_idle_task ( remove_defaults ) ;
68
+ queue_micro_task ( remove_defaults ) ;
69
69
add_form_reset_listener ( ) ;
70
70
}
71
71
Original file line number Diff line number Diff line change 1
1
import { run_all } from '../../shared/utils.js' ;
2
2
import { is_flushing_sync } from '../reactivity/batch.js' ;
3
3
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
-
10
4
/** @type {Array<() => void> } */
11
5
let micro_tasks = [ ] ;
12
6
13
- /** @type {Array<() => void> } */
14
- let idle_tasks = [ ] ;
15
-
16
7
function run_micro_tasks ( ) {
17
8
var tasks = micro_tasks ;
18
9
micro_tasks = [ ] ;
19
10
run_all ( tasks ) ;
20
11
}
21
12
22
- function run_idle_tasks ( ) {
23
- var tasks = idle_tasks ;
24
- idle_tasks = [ ] ;
25
- run_all ( tasks ) ;
26
- }
27
-
28
13
export function has_pending_tasks ( ) {
29
- return micro_tasks . length > 0 || idle_tasks . length > 0 ;
14
+ return micro_tasks . length > 0 ;
30
15
}
31
16
32
17
/**
@@ -51,26 +36,11 @@ export function queue_micro_task(fn) {
51
36
micro_tasks . push ( fn ) ;
52
37
}
53
38
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
-
65
39
/**
66
40
* Synchronously run any queued tasks.
67
41
*/
68
42
export function flush_tasks ( ) {
69
43
if ( micro_tasks . length > 0 ) {
70
44
run_micro_tasks ( ) ;
71
45
}
72
-
73
- if ( idle_tasks . length > 0 ) {
74
- run_idle_tasks ( ) ;
75
- }
76
46
}
You can’t perform that action at this time.
0 commit comments