make everything non-breaking for people who dont opt in

pull/16197/head
Rich Harris 4 months ago
parent a2bc5f7d34
commit bc050c34b7

@ -5,6 +5,7 @@ import { init_array_prototype_warnings } from '../dev/equality.js';
import { get_descriptor, is_extensible } from '../../shared/utils.js';
import { active_effect } from '../runtime.js';
import { EFFECT_RAN } from '../constants.js';
import { async_mode_flag } from '../../flags/index.js';
// export these for reference in the compiled code, making global name deduplication unnecessary
/** @type {Window} */
@ -214,6 +215,8 @@ export function clear_text_content(node) {
* current `<svelte:boundary>`
*/
export function should_defer_append() {
if (!async_mode_flag) return false;
var flags = /** @type {Effect} */ (active_effect).f;
return (flags & EFFECT_RAN) !== 0;
}

@ -45,7 +45,7 @@ import {
} from './reactivity/deriveds.js';
import * as e from './errors.js';
import { FILENAME } from '../../constants.js';
import { tracing_mode_flag } from '../flags/index.js';
import { async_mode_flag, tracing_mode_flag } from '../flags/index.js';
import { tracing_expressions, get_stack } from './dev/tracing.js';
import {
component_context,
@ -823,7 +823,19 @@ export function process_effects(batch, root) {
} else if (is_branch) {
effect.f ^= CLEAN;
} else if ((flags & RENDER_EFFECT) !== 0) {
batch.render_effects.push(effect);
// we need to branch here because in legacy mode we run render effects
// before running block effects
if (async_mode_flag) {
batch.render_effects.push(effect);
} else {
try {
if (check_dirtiness(effect)) {
update_effect(effect);
}
} catch (error) {
handle_error(error, effect, null, effect.ctx);
}
}
} else if ((flags & EFFECT) !== 0) {
batch.effects.push(effect);
}

@ -2,12 +2,6 @@ import { test } from '../../test';
import { flushSync } from 'svelte';
export default test({
// this test breaks because of the changes required to make async work
// (namely, running blocks before other render effects including
// beforeUpdate and $effect.pre). Not sure if there's a good
// solution. We may be forced to release 6.0
skip: true,
async test({ assert, target, logs }) {
const input = /** @type {HTMLInputElement} */ (target.querySelector('input'));
assert.equal(input?.value, 'rich');

Loading…
Cancel
Save