@@ -134,20 +134,19 @@ function create_effect(type, fn, sync, push = true) {
134134 }
135135
136136 if ( push ) {
137- var e = /** @type {Effect | null } */ ( effect ) ;
137+ /** @type {Effect | null } */
138+ var e = effect ;
138139
139140 // if an effect has already ran and doesn't need to be kept in the tree
140141 // (because it won't re-run, has no DOM, and has no teardown etc)
141142 // then we skip it and go to its child (if any)
142143 if (
143- e !== null &&
144+ sync &&
144145 e . deps === null &&
145146 e . teardown === null &&
146147 e . nodes_start === null &&
147148 e . first === e . last &&
148149 ( e . f & EFFECT_RAN ) !== 0 &&
149- ( e . f & ROOT_EFFECT ) === 0 &&
150- ( e . f & BRANCH_EFFECT ) === 0 &&
151150 ( e . f & EFFECT_PRESERVED ) === 0
152151 ) {
153152 e = e . first ;
@@ -253,7 +252,7 @@ export function inspect_effect(fn) {
253252 */
254253export function effect_root ( fn ) {
255254 Batch . ensure ( ) ;
256- const effect = create_effect ( ROOT_EFFECT , fn , true ) ;
255+ const effect = create_effect ( ROOT_EFFECT | EFFECT_PRESERVED , fn , true ) ;
257256
258257 return ( ) => {
259258 destroy_effect ( effect ) ;
@@ -267,7 +266,7 @@ export function effect_root(fn) {
267266 */
268267export function component_root ( fn ) {
269268 Batch . ensure ( ) ;
270- const effect = create_effect ( ROOT_EFFECT , fn , true ) ;
269+ const effect = create_effect ( ROOT_EFFECT | EFFECT_PRESERVED , fn , true ) ;
271270
272271 return ( options = { } ) => {
273272 return new Promise ( ( fulfil ) => {
@@ -386,7 +385,7 @@ export function block(fn, flags = 0) {
386385 * @param {boolean } [push]
387386 */
388387export function branch ( fn , push = true ) {
389- return create_effect ( BRANCH_EFFECT , fn , true , push ) ;
388+ return create_effect ( BRANCH_EFFECT | EFFECT_PRESERVED , fn , true , push ) ;
390389}
391390
392391/**
0 commit comments