@@ -38,6 +38,7 @@ import { queue_micro_task } from '../task.js';
3838import { active_effect , active_reaction , get } from '../../runtime.js' ;
3939import { DEV } from 'esm-env' ;
4040import { derived_safe_equal } from '../../reactivity/deriveds.js' ;
41+ import { find_boundary } from './boundary.js' ;
4142
4243/**
4344 * The row of a keyed each block that is currently updating. We track this
@@ -136,6 +137,8 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
136137
137138 var was_empty = false ;
138139
140+ var boundary = find_boundary ( active_effect ) ;
141+
139142 // TODO: ideally we could use derived for runes mode but because of the ability
140143 // to use a store which can be mutated, we can't do that here as mutating a store
141144 // will still result in the collection array being the same from the store
@@ -145,8 +148,29 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
145148 return is_array ( collection ) ? collection : collection == null ? [ ] : array_from ( collection ) ;
146149 } ) ;
147150
151+ /** @type {V[] } */
152+ var array ;
153+
154+ function commit ( ) {
155+ reconcile ( array , state , anchor , render_fn , flags , get_key , get_collection ) ;
156+
157+ if ( fallback_fn !== null ) {
158+ if ( array . length === 0 ) {
159+ if ( fallback ) {
160+ resume_effect ( fallback ) ;
161+ } else {
162+ fallback = branch ( ( ) => fallback_fn ( anchor ) ) ;
163+ }
164+ } else if ( fallback !== null ) {
165+ pause_effect ( fallback , ( ) => {
166+ fallback = null ;
167+ } ) ;
168+ }
169+ }
170+ }
171+
148172 block ( ( ) => {
149- var array = get ( each_array ) ;
173+ array = get ( each_array ) ;
150174 var length = array . length ;
151175
152176 if ( was_empty && length === 0 ) {
@@ -223,21 +247,7 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
223247 fallback = branch ( ( ) => fallback_fn ( anchor ) ) ;
224248 }
225249 } else {
226- reconcile ( array , state , anchor , render_fn , flags , get_key , get_collection ) ;
227-
228- if ( fallback_fn !== null ) {
229- if ( length === 0 ) {
230- if ( fallback ) {
231- resume_effect ( fallback ) ;
232- } else {
233- fallback = branch ( ( ) => fallback_fn ( anchor ) ) ;
234- }
235- } else if ( fallback !== null ) {
236- pause_effect ( fallback , ( ) => {
237- fallback = null ;
238- } ) ;
239- }
240- }
250+ commit ( ) ;
241251 }
242252
243253 if ( mismatch ) {
0 commit comments