File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed
tests/runtime-legacy/samples/lifecycle-render-beforeUpdate Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { init_array_prototype_warnings } from '../dev/equality.js';
55import { get_descriptor , is_extensible } from '../../shared/utils.js' ;
66import { active_effect } from '../runtime.js' ;
77import { EFFECT_RAN } from '../constants.js' ;
8+ import { async_mode_flag } from '../../flags/index.js' ;
89
910// export these for reference in the compiled code, making global name deduplication unnecessary
1011/** @type {Window } */
@@ -214,6 +215,8 @@ export function clear_text_content(node) {
214215 * current `<svelte:boundary>`
215216 */
216217export function should_defer_append ( ) {
218+ if ( ! async_mode_flag ) return false ;
219+
217220 var flags = /** @type {Effect } */ ( active_effect ) . f ;
218221 return ( flags & EFFECT_RAN ) !== 0 ;
219222}
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ import {
4545} from './reactivity/deriveds.js' ;
4646import * as e from './errors.js' ;
4747import { FILENAME } from '../../constants.js' ;
48- import { tracing_mode_flag } from '../flags/index.js' ;
48+ import { async_mode_flag , tracing_mode_flag } from '../flags/index.js' ;
4949import { tracing_expressions , get_stack } from './dev/tracing.js' ;
5050import {
5151 component_context ,
@@ -823,7 +823,19 @@ export function process_effects(batch, root) {
823823 } else if ( is_branch ) {
824824 effect . f ^= CLEAN ;
825825 } else if ( ( flags & RENDER_EFFECT ) !== 0 ) {
826- batch . render_effects . push ( effect ) ;
826+ // we need to branch here because in legacy mode we run render effects
827+ // before running block effects
828+ if ( async_mode_flag ) {
829+ batch . render_effects . push ( effect ) ;
830+ } else {
831+ try {
832+ if ( check_dirtiness ( effect ) ) {
833+ update_effect ( effect ) ;
834+ }
835+ } catch ( error ) {
836+ handle_error ( error , effect , null , effect . ctx ) ;
837+ }
838+ }
827839 } else if ( ( flags & EFFECT ) !== 0 ) {
828840 batch . effects . push ( effect ) ;
829841 }
Original file line number Diff line number Diff line change @@ -2,12 +2,6 @@ import { test } from '../../test';
22import { flushSync } from 'svelte' ;
33
44export default test ( {
5- // this test breaks because of the changes required to make async work
6- // (namely, running blocks before other render effects including
7- // beforeUpdate and $effect.pre). Not sure if there's a good
8- // solution. We may be forced to release 6.0
9- skip : true ,
10-
115 async test ( { assert, target, logs } ) {
126 const input = /** @type {HTMLInputElement } */ ( target . querySelector ( 'input' ) ) ;
137 assert . equal ( input ?. value , 'rich' ) ;
You can’t perform that action at this time.
0 commit comments