svelte 5.39.5 → 5.39.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/index.js +1 -1
- package/package.json +2 -2
- package/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js +4 -1
- package/src/compiler/phases/3-transform/client/visitors/TitleElement.js +12 -1
- package/src/compiler/phases/3-transform/server/visitors/RegularElement.js +30 -41
- package/src/compiler/phases/3-transform/server/visitors/shared/component.js +6 -1
- package/src/compiler/phases/3-transform/server/visitors/shared/element.js +86 -22
- package/src/compiler/warnings.js +2 -2
- package/src/internal/client/dom/blocks/await.js +2 -2
- package/src/internal/client/dom/elements/attributes.js +2 -2
- package/src/internal/client/dom/task.js +1 -35
- package/src/internal/client/reactivity/async.js +0 -1
- package/src/internal/client/reactivity/batch.js +140 -103
- package/src/internal/client/reactivity/deriveds.js +26 -24
- package/src/internal/client/render.js +1 -1
- package/src/internal/client/runtime.js +7 -1
- package/src/internal/server/renderer.js +15 -4
- package/src/version.js +1 -1
- package/types/index.d.ts.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { Derived, Effect, Source } from '#client' */
|
|
1
|
+
/** @import { Derived, Effect, Source, Value } from '#client' */
|
|
2
2
|
import {
|
|
3
3
|
BLOCK_EFFECT,
|
|
4
4
|
BRANCH_EFFECT,
|
|
@@ -10,10 +10,11 @@ import {
|
|
|
10
10
|
INERT,
|
|
11
11
|
RENDER_EFFECT,
|
|
12
12
|
ROOT_EFFECT,
|
|
13
|
-
MAYBE_DIRTY
|
|
13
|
+
MAYBE_DIRTY,
|
|
14
|
+
DERIVED
|
|
14
15
|
} from '#client/constants';
|
|
15
16
|
import { async_mode_flag } from '../../flags/index.js';
|
|
16
|
-
import { deferred, define_property } from '../../shared/utils.js';
|
|
17
|
+
import { deferred, define_property, noop } from '../../shared/utils.js';
|
|
17
18
|
import {
|
|
18
19
|
active_effect,
|
|
19
20
|
is_dirty,
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
update_effect
|
|
24
25
|
} from '../runtime.js';
|
|
25
26
|
import * as e from '../errors.js';
|
|
26
|
-
import { flush_tasks,
|
|
27
|
+
import { flush_tasks, queue_micro_task } from '../dom/task.js';
|
|
27
28
|
import { DEV } from 'esm-env';
|
|
28
29
|
import { invoke_error_boundary } from '../error-handling.js';
|
|
29
30
|
import { old_values } from './sources.js';
|
|
@@ -97,22 +98,8 @@ export class Batch {
|
|
|
97
98
|
#deferred = null;
|
|
98
99
|
|
|
99
100
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*/
|
|
103
|
-
#neutered = false;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Async effects (created inside `async_derived`) encountered during processing.
|
|
107
|
-
* These run after the rest of the batch has updated, since they should
|
|
108
|
-
* always have the latest values
|
|
109
|
-
* @type {Effect[]}
|
|
110
|
-
*/
|
|
111
|
-
#async_effects = [];
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The same as `#async_effects`, but for effects inside a newly-created
|
|
115
|
-
* `<svelte:boundary>` — these do not prevent the batch from committing
|
|
101
|
+
* Async effects inside a newly-created `<svelte:boundary>`
|
|
102
|
+
* — these do not prevent the batch from committing
|
|
116
103
|
* @type {Effect[]}
|
|
117
104
|
*/
|
|
118
105
|
#boundary_async_effects = [];
|
|
@@ -165,32 +152,7 @@ export class Batch {
|
|
|
165
152
|
|
|
166
153
|
previous_batch = null;
|
|
167
154
|
|
|
168
|
-
|
|
169
|
-
var current_values = null;
|
|
170
|
-
|
|
171
|
-
// if there are multiple batches, we are 'time travelling' —
|
|
172
|
-
// we need to undo the changes belonging to any batch
|
|
173
|
-
// other than the current one
|
|
174
|
-
if (async_mode_flag && batches.size > 1) {
|
|
175
|
-
current_values = new Map();
|
|
176
|
-
batch_deriveds = new Map();
|
|
177
|
-
|
|
178
|
-
for (const [source, current] of this.current) {
|
|
179
|
-
current_values.set(source, { v: source.v, wv: source.wv });
|
|
180
|
-
source.v = current;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
for (const batch of batches) {
|
|
184
|
-
if (batch === this) continue;
|
|
185
|
-
|
|
186
|
-
for (const [source, previous] of batch.#previous) {
|
|
187
|
-
if (!current_values.has(source)) {
|
|
188
|
-
current_values.set(source, { v: source.v, wv: source.wv });
|
|
189
|
-
source.v = previous;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
155
|
+
var revert = Batch.apply(this);
|
|
194
156
|
|
|
195
157
|
for (const root of root_effects) {
|
|
196
158
|
this.#traverse_effect_tree(root);
|
|
@@ -198,7 +160,7 @@ export class Batch {
|
|
|
198
160
|
|
|
199
161
|
// if we didn't start any new async work, and no async work
|
|
200
162
|
// is outstanding from a previous flush, commit
|
|
201
|
-
if (this.#
|
|
163
|
+
if (this.#pending === 0) {
|
|
202
164
|
this.#commit();
|
|
203
165
|
|
|
204
166
|
var render_effects = this.#render_effects;
|
|
@@ -210,21 +172,12 @@ export class Batch {
|
|
|
210
172
|
|
|
211
173
|
// If sources are written to, then work needs to happen in a separate batch, else prior sources would be mixed with
|
|
212
174
|
// newly updated sources, which could lead to infinite loops when effects run over and over again.
|
|
213
|
-
previous_batch =
|
|
175
|
+
previous_batch = this;
|
|
214
176
|
current_batch = null;
|
|
215
177
|
|
|
216
178
|
flush_queued_effects(render_effects);
|
|
217
179
|
flush_queued_effects(effects);
|
|
218
180
|
|
|
219
|
-
// Reinstate the current batch if there was no new one created, as `process()` runs in a loop in `flush_effects()`.
|
|
220
|
-
// That method expects `current_batch` to be set, and could run the loop again if effects result in new effects
|
|
221
|
-
// being scheduled but without writes happening in which case no new batch is created.
|
|
222
|
-
if (current_batch === null) {
|
|
223
|
-
current_batch = this;
|
|
224
|
-
} else {
|
|
225
|
-
batches.delete(this);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
181
|
this.#deferred?.resolve();
|
|
229
182
|
} else {
|
|
230
183
|
this.#defer_effects(this.#render_effects);
|
|
@@ -232,27 +185,12 @@ export class Batch {
|
|
|
232
185
|
this.#defer_effects(this.#block_effects);
|
|
233
186
|
}
|
|
234
187
|
|
|
235
|
-
|
|
236
|
-
for (const [source, { v, wv }] of current_values) {
|
|
237
|
-
// reset the source to the current value (unless
|
|
238
|
-
// it got a newer value as a result of effects running)
|
|
239
|
-
if (source.wv <= wv) {
|
|
240
|
-
source.v = v;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
batch_deriveds = null;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
for (const effect of this.#async_effects) {
|
|
248
|
-
update_effect(effect);
|
|
249
|
-
}
|
|
188
|
+
revert();
|
|
250
189
|
|
|
251
190
|
for (const effect of this.#boundary_async_effects) {
|
|
252
191
|
update_effect(effect);
|
|
253
192
|
}
|
|
254
193
|
|
|
255
|
-
this.#async_effects = [];
|
|
256
194
|
this.#boundary_async_effects = [];
|
|
257
195
|
}
|
|
258
196
|
|
|
@@ -281,12 +219,8 @@ export class Batch {
|
|
|
281
219
|
} else if (async_mode_flag && (flags & RENDER_EFFECT) !== 0) {
|
|
282
220
|
this.#render_effects.push(effect);
|
|
283
221
|
} else if ((flags & CLEAN) === 0) {
|
|
284
|
-
if ((flags & ASYNC) !== 0) {
|
|
285
|
-
|
|
286
|
-
? this.#boundary_async_effects
|
|
287
|
-
: this.#async_effects;
|
|
288
|
-
|
|
289
|
-
effects.push(effect);
|
|
222
|
+
if ((flags & ASYNC) !== 0 && effect.b?.is_pending()) {
|
|
223
|
+
this.#boundary_async_effects.push(effect);
|
|
290
224
|
} else if (is_dirty(effect)) {
|
|
291
225
|
if ((effect.f & BLOCK_EFFECT) !== 0) this.#block_effects.push(effect);
|
|
292
226
|
update_effect(effect);
|
|
@@ -359,25 +293,17 @@ export class Batch {
|
|
|
359
293
|
}
|
|
360
294
|
}
|
|
361
295
|
|
|
362
|
-
neuter() {
|
|
363
|
-
this.#neutered = true;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
296
|
flush() {
|
|
367
297
|
if (queued_root_effects.length > 0) {
|
|
298
|
+
this.activate();
|
|
368
299
|
flush_effects();
|
|
369
|
-
} else {
|
|
370
|
-
this.#commit();
|
|
371
|
-
}
|
|
372
300
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
if (this.#pending === 0) {
|
|
380
|
-
batches.delete(this);
|
|
301
|
+
if (current_batch !== null && current_batch !== this) {
|
|
302
|
+
// this can happen if a new batch was created during `flush_effects()`
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
} else if (this.#pending === 0) {
|
|
306
|
+
this.#commit();
|
|
381
307
|
}
|
|
382
308
|
|
|
383
309
|
this.deactivate();
|
|
@@ -387,13 +313,59 @@ export class Batch {
|
|
|
387
313
|
* Append and remove branches to/from the DOM
|
|
388
314
|
*/
|
|
389
315
|
#commit() {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
fn();
|
|
393
|
-
}
|
|
316
|
+
for (const fn of this.#callbacks) {
|
|
317
|
+
fn();
|
|
394
318
|
}
|
|
395
319
|
|
|
396
320
|
this.#callbacks.clear();
|
|
321
|
+
|
|
322
|
+
// If there are other pending batches, they now need to be 'rebased' —
|
|
323
|
+
// in other words, we re-run block/async effects with the newly
|
|
324
|
+
// committed state, unless the batch in question has a more
|
|
325
|
+
// recent value for a given source
|
|
326
|
+
if (batches.size > 1) {
|
|
327
|
+
this.#previous.clear();
|
|
328
|
+
|
|
329
|
+
let is_earlier = true;
|
|
330
|
+
|
|
331
|
+
for (const batch of batches) {
|
|
332
|
+
if (batch === this) {
|
|
333
|
+
is_earlier = false;
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
for (const [source, value] of this.current) {
|
|
338
|
+
if (batch.current.has(source)) {
|
|
339
|
+
if (is_earlier) {
|
|
340
|
+
// bring the value up to date
|
|
341
|
+
batch.current.set(source, value);
|
|
342
|
+
} else {
|
|
343
|
+
// later batch has more recent value,
|
|
344
|
+
// no need to re-run these effects
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
mark_effects(source);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (queued_root_effects.length > 0) {
|
|
353
|
+
current_batch = batch;
|
|
354
|
+
const revert = Batch.apply(batch);
|
|
355
|
+
|
|
356
|
+
for (const root of queued_root_effects) {
|
|
357
|
+
batch.#traverse_effect_tree(root);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
queued_root_effects = [];
|
|
361
|
+
revert();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
current_batch = null;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
batches.delete(this);
|
|
397
369
|
}
|
|
398
370
|
|
|
399
371
|
increment() {
|
|
@@ -414,9 +386,6 @@ export class Batch {
|
|
|
414
386
|
schedule_effect(e);
|
|
415
387
|
}
|
|
416
388
|
|
|
417
|
-
this.#render_effects = [];
|
|
418
|
-
this.#effects = [];
|
|
419
|
-
|
|
420
389
|
this.flush();
|
|
421
390
|
} else {
|
|
422
391
|
this.deactivate();
|
|
@@ -456,6 +425,51 @@ export class Batch {
|
|
|
456
425
|
static enqueue(task) {
|
|
457
426
|
queue_micro_task(task);
|
|
458
427
|
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* @param {Batch} current_batch
|
|
431
|
+
*/
|
|
432
|
+
static apply(current_batch) {
|
|
433
|
+
if (!async_mode_flag || batches.size === 1) {
|
|
434
|
+
return noop;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// if there are multiple batches, we are 'time travelling' —
|
|
438
|
+
// we need to undo the changes belonging to any batch
|
|
439
|
+
// other than the current one
|
|
440
|
+
|
|
441
|
+
/** @type {Map<Source, { v: unknown, wv: number }>} */
|
|
442
|
+
var current_values = new Map();
|
|
443
|
+
batch_deriveds = new Map();
|
|
444
|
+
|
|
445
|
+
for (const [source, current] of current_batch.current) {
|
|
446
|
+
current_values.set(source, { v: source.v, wv: source.wv });
|
|
447
|
+
source.v = current;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
for (const batch of batches) {
|
|
451
|
+
if (batch === current_batch) continue;
|
|
452
|
+
|
|
453
|
+
for (const [source, previous] of batch.#previous) {
|
|
454
|
+
if (!current_values.has(source)) {
|
|
455
|
+
current_values.set(source, { v: source.v, wv: source.wv });
|
|
456
|
+
source.v = previous;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return () => {
|
|
462
|
+
for (const [source, { v, wv }] of current_values) {
|
|
463
|
+
// reset the source to the current value (unless
|
|
464
|
+
// it got a newer value as a result of effects running)
|
|
465
|
+
if (source.wv <= wv) {
|
|
466
|
+
source.v = v;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
batch_deriveds = null;
|
|
471
|
+
};
|
|
472
|
+
}
|
|
459
473
|
}
|
|
460
474
|
|
|
461
475
|
/**
|
|
@@ -478,14 +492,17 @@ export function flushSync(fn) {
|
|
|
478
492
|
var result;
|
|
479
493
|
|
|
480
494
|
if (fn) {
|
|
481
|
-
|
|
495
|
+
if (current_batch !== null) {
|
|
496
|
+
flush_effects();
|
|
497
|
+
}
|
|
498
|
+
|
|
482
499
|
result = fn();
|
|
483
500
|
}
|
|
484
501
|
|
|
485
502
|
while (true) {
|
|
486
503
|
flush_tasks();
|
|
487
504
|
|
|
488
|
-
if (queued_root_effects.length === 0
|
|
505
|
+
if (queued_root_effects.length === 0) {
|
|
489
506
|
current_batch?.flush();
|
|
490
507
|
|
|
491
508
|
// we need to check again, in case we just updated an `$effect.pending()`
|
|
@@ -624,6 +641,26 @@ function flush_queued_effects(effects) {
|
|
|
624
641
|
eager_block_effects = null;
|
|
625
642
|
}
|
|
626
643
|
|
|
644
|
+
/**
|
|
645
|
+
* This is similar to `mark_reactions`, but it only marks async/block effects
|
|
646
|
+
* so that these can re-run after another batch has been committed
|
|
647
|
+
* @param {Value} value
|
|
648
|
+
*/
|
|
649
|
+
function mark_effects(value) {
|
|
650
|
+
if (value.reactions !== null) {
|
|
651
|
+
for (const reaction of value.reactions) {
|
|
652
|
+
const flags = reaction.f;
|
|
653
|
+
|
|
654
|
+
if ((flags & DERIVED) !== 0) {
|
|
655
|
+
mark_effects(/** @type {Derived} */ (reaction));
|
|
656
|
+
} else if ((flags & (ASYNC | BLOCK_EFFECT)) !== 0) {
|
|
657
|
+
set_signal_status(reaction, DIRTY);
|
|
658
|
+
schedule_effect(/** @type {Effect} */ (reaction));
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
627
664
|
/**
|
|
628
665
|
* @param {Effect} signal
|
|
629
666
|
* @returns {void}
|
|
@@ -26,15 +26,16 @@ import {
|
|
|
26
26
|
import { equals, safe_equals } from './equality.js';
|
|
27
27
|
import * as e from '../errors.js';
|
|
28
28
|
import * as w from '../warnings.js';
|
|
29
|
-
import { async_effect, destroy_effect } from './effects.js';
|
|
29
|
+
import { async_effect, destroy_effect, teardown } from './effects.js';
|
|
30
30
|
import { inspect_effects, internal_set, set_inspect_effects, source } from './sources.js';
|
|
31
31
|
import { get_stack } from '../dev/tracing.js';
|
|
32
|
-
import { tracing_mode_flag } from '../../flags/index.js';
|
|
32
|
+
import { async_mode_flag, tracing_mode_flag } from '../../flags/index.js';
|
|
33
33
|
import { Boundary } from '../dom/blocks/boundary.js';
|
|
34
34
|
import { component_context } from '../context.js';
|
|
35
35
|
import { UNINITIALIZED } from '../../../constants.js';
|
|
36
36
|
import { batch_deriveds, current_batch } from './batch.js';
|
|
37
37
|
import { unset_context } from './async.js';
|
|
38
|
+
import { deferred } from '../../shared/utils.js';
|
|
38
39
|
|
|
39
40
|
/** @type {Effect | null} */
|
|
40
41
|
export let current_async_effect = null;
|
|
@@ -109,37 +110,40 @@ export function async_derived(fn, location) {
|
|
|
109
110
|
var promise = /** @type {Promise<V>} */ (/** @type {unknown} */ (undefined));
|
|
110
111
|
var signal = source(/** @type {V} */ (UNINITIALIZED));
|
|
111
112
|
|
|
112
|
-
/** @type {Promise<V> | null} */
|
|
113
|
-
var prev = null;
|
|
114
|
-
|
|
115
113
|
// only suspend in async deriveds created on initialisation
|
|
116
114
|
var should_suspend = !active_reaction;
|
|
117
115
|
|
|
116
|
+
/** @type {Map<Batch, ReturnType<typeof deferred<V>>>} */
|
|
117
|
+
var deferreds = new Map();
|
|
118
|
+
|
|
118
119
|
async_effect(() => {
|
|
119
120
|
if (DEV) current_async_effect = active_effect;
|
|
120
121
|
|
|
122
|
+
/** @type {ReturnType<typeof deferred<V>>} */
|
|
123
|
+
var d = deferred();
|
|
124
|
+
promise = d.promise;
|
|
125
|
+
|
|
121
126
|
try {
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
if (prev) Promise.resolve(p).catch(() => {}); // avoid unhandled rejection
|
|
127
|
+
// If this code is changed at some point, make sure to still access the then property
|
|
128
|
+
// of fn() to read any signals it might access, so that we track them as dependencies.
|
|
129
|
+
Promise.resolve(fn()).then(d.resolve, d.reject);
|
|
126
130
|
} catch (error) {
|
|
127
|
-
|
|
131
|
+
d.reject(error);
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
if (DEV) current_async_effect = null;
|
|
131
135
|
|
|
132
|
-
var r = () => p;
|
|
133
|
-
promise = prev?.then(r, r) ?? Promise.resolve(p);
|
|
134
|
-
|
|
135
|
-
prev = promise;
|
|
136
|
-
|
|
137
136
|
var batch = /** @type {Batch} */ (current_batch);
|
|
138
137
|
var pending = boundary.is_pending();
|
|
139
138
|
|
|
140
139
|
if (should_suspend) {
|
|
141
140
|
boundary.update_pending_count(1);
|
|
142
|
-
if (!pending)
|
|
141
|
+
if (!pending) {
|
|
142
|
+
batch.increment();
|
|
143
|
+
|
|
144
|
+
deferreds.get(batch)?.reject(STALE_REACTION);
|
|
145
|
+
deferreds.set(batch, d);
|
|
146
|
+
}
|
|
143
147
|
}
|
|
144
148
|
|
|
145
149
|
/**
|
|
@@ -147,8 +151,6 @@ export function async_derived(fn, location) {
|
|
|
147
151
|
* @param {unknown} error
|
|
148
152
|
*/
|
|
149
153
|
const handler = (value, error = undefined) => {
|
|
150
|
-
prev = null;
|
|
151
|
-
|
|
152
154
|
current_async_effect = null;
|
|
153
155
|
|
|
154
156
|
if (!pending) batch.activate();
|
|
@@ -187,12 +189,12 @@ export function async_derived(fn, location) {
|
|
|
187
189
|
unset_context();
|
|
188
190
|
};
|
|
189
191
|
|
|
190
|
-
promise.then(handler, (e) => handler(null, e || 'unknown'));
|
|
192
|
+
d.promise.then(handler, (e) => handler(null, e || 'unknown'));
|
|
193
|
+
});
|
|
191
194
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
};
|
|
195
|
+
teardown(() => {
|
|
196
|
+
for (const d of deferreds.values()) {
|
|
197
|
+
d.reject(STALE_REACTION);
|
|
196
198
|
}
|
|
197
199
|
});
|
|
198
200
|
|
|
@@ -231,7 +233,7 @@ export function async_derived(fn, location) {
|
|
|
231
233
|
export function user_derived(fn) {
|
|
232
234
|
const d = derived(fn);
|
|
233
235
|
|
|
234
|
-
push_reaction_value(d);
|
|
236
|
+
if (!async_mode_flag) push_reaction_value(d);
|
|
235
237
|
|
|
236
238
|
return d;
|
|
237
239
|
}
|
|
@@ -143,7 +143,7 @@ export function hydrate(component, options) {
|
|
|
143
143
|
e.hydration_failed();
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
// If an error
|
|
146
|
+
// If an error occurred above, the operations might not yet have been initialised.
|
|
147
147
|
init_operations();
|
|
148
148
|
clear_text_content(target);
|
|
149
149
|
|
|
@@ -500,7 +500,13 @@ export function update_effect(effect) {
|
|
|
500
500
|
*/
|
|
501
501
|
export async function tick() {
|
|
502
502
|
if (async_mode_flag) {
|
|
503
|
-
return new Promise((f) =>
|
|
503
|
+
return new Promise((f) => {
|
|
504
|
+
// Race them against each other - in almost all cases requestAnimationFrame will fire first,
|
|
505
|
+
// but e.g. in case the window is not focused or a view transition happens, requestAnimationFrame
|
|
506
|
+
// will be delayed and setTimeout helps us resolve fast enough in that case
|
|
507
|
+
requestAnimationFrame(() => f());
|
|
508
|
+
setTimeout(() => f());
|
|
509
|
+
});
|
|
504
510
|
}
|
|
505
511
|
|
|
506
512
|
await Promise.resolve();
|
|
@@ -160,9 +160,16 @@ export class Renderer {
|
|
|
160
160
|
/**
|
|
161
161
|
* @param {Record<string, any>} attrs
|
|
162
162
|
* @param {(renderer: Renderer) => void} fn
|
|
163
|
+
* @param {string | undefined} [css_hash]
|
|
164
|
+
* @param {Record<string, boolean> | undefined} [classes]
|
|
165
|
+
* @param {Record<string, string> | undefined} [styles]
|
|
166
|
+
* @param {number | undefined} [flags]
|
|
167
|
+
* @returns {void}
|
|
163
168
|
*/
|
|
164
|
-
select(
|
|
165
|
-
|
|
169
|
+
select(attrs, fn, css_hash, classes, styles, flags) {
|
|
170
|
+
const { value, ...select_attrs } = attrs;
|
|
171
|
+
|
|
172
|
+
this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
|
|
166
173
|
this.child((renderer) => {
|
|
167
174
|
renderer.local.select_value = value;
|
|
168
175
|
fn(renderer);
|
|
@@ -173,9 +180,13 @@ export class Renderer {
|
|
|
173
180
|
/**
|
|
174
181
|
* @param {Record<string, any>} attrs
|
|
175
182
|
* @param {string | number | boolean | ((renderer: Renderer) => void)} body
|
|
183
|
+
* @param {string | undefined} [css_hash]
|
|
184
|
+
* @param {Record<string, boolean> | undefined} [classes]
|
|
185
|
+
* @param {Record<string, string> | undefined} [styles]
|
|
186
|
+
* @param {number | undefined} [flags]
|
|
176
187
|
*/
|
|
177
|
-
option(attrs, body) {
|
|
178
|
-
this.#out.push(`<option${attributes(attrs)}`);
|
|
188
|
+
option(attrs, body, css_hash, classes, styles, flags) {
|
|
189
|
+
this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
|
|
179
190
|
|
|
180
191
|
/**
|
|
181
192
|
* @param {Renderer} renderer
|
package/src/version.js
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -260,6 +260,6 @@
|
|
|
260
260
|
null,
|
|
261
261
|
null
|
|
262
262
|
],
|
|
263
|
-
"mappings": ";;;;;;;kBAUiBA,2BAA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkC/BC,eAAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAwEhBC,kBAAkBA;;;;;;;;;;;;;;;;;;;;;;;;kBAwBbC,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoCbC,oBAAoBA;;;;;;;;;;;;;;;;;;;;;;;;aAwBrBC,eAAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAiCfC,cAAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA6BdC,aAAaA;;;;;;;;;;;;;;;;;;;;;;;kBAuBRC,OAAOA;;;;;;;;;;;;;;;;kBAgBPC,eAAeA;;;;;;;;;;;;;;;;aAgBpBC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCzPRC,cAAcA;;;;;;;;;;;;iBAsBdC,OAAOA;;;;;;;;iBAwBPC,SAASA;;;;;;;;;;;;;;;;;;;;;;iBA0CTC,qBAAqBA;;;;;;;;;;iBA2CrBC,YAAYA;;;;;;;;;;iBAuBZC,WAAWA;;;;;
|
|
263
|
+
"mappings": ";;;;;;;kBAUiBA,2BAA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkC/BC,eAAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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