pull/16197/head
Rich Harris 4 months ago
parent 54e720b02b
commit c3ad8c48f4

@ -160,9 +160,15 @@ export function async_derived(fn, location) {
if (error) {
if (error !== STALE_REACTION) {
signal.f |= ASYNC_ERROR;
// @ts-expect-error the error is the wrong type, but we don't care
internal_set(signal, error);
}
} else {
if ((signal.f & ASYNC_ERROR) !== 0) {
signal.f ^= ASYNC_ERROR;
}
internal_set(signal, value);
if (DEV && location !== undefined) {

@ -339,7 +339,7 @@ export function render_effect(fn, flags = 0) {
* @param {Array<() => Promise<any>>} async
*/
export function template_effect(fn, sync = [], async = [], d = derived) {
var batch = /** @type {Batch} */ (current_batch);
var batch = current_batch;
var parent = /** @type {Effect} */ (active_effect);
if (async.length > 0) {
@ -349,12 +349,12 @@ export function template_effect(fn, sync = [], async = [], d = derived) {
if ((parent.f & DESTROYED) !== 0) return;
// TODO probably need to do this in async.js as well
batch.restore();
batch?.restore();
restore();
create_template_effect(fn, [...sync.map(d), ...result]);
batch.flush();
batch?.flush();
});
} else {
create_template_effect(fn, sync.map(d));

@ -10,6 +10,7 @@ export default test({
flushSync(() => button1.click());
await Promise.resolve();
await Promise.resolve();
await Promise.resolve();
flushSync();
assert.htmlEqual(
target.innerHTML,

Loading…
Cancel
Save