@@ -35,7 +35,7 @@ import { source, mutable_source, internal_set } from '../../reactivity/sources.j
3535import { array_from , is_array } from '../../../shared/utils.js' ;
3636import { INERT } from '../../constants.js' ;
3737import { queue_micro_task } from '../task.js' ;
38- import { active_effect } from '../../runtime.js' ;
38+ import { active_effect , active_reaction } from '../../runtime.js' ;
3939
4040/**
4141 * The row of a keyed each block that is currently updating. We track this
@@ -204,7 +204,8 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
204204 }
205205
206206 if ( ! hydrating ) {
207- reconcile ( array , state , anchor , render_fn , flags , get_key ) ;
207+ var effect = /** @type {Effect } */ ( active_reaction ) ;
208+ reconcile ( array , state , anchor , render_fn , flags , ( effect . f & INERT ) !== 0 , get_key ) ;
208209 }
209210
210211 if ( fallback_fn !== null ) {
@@ -248,10 +249,11 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
248249 * @param {Element | Comment | Text } anchor
249250 * @param {(anchor: Node, item: MaybeSource<V>, index: number | Source<number>) => void } render_fn
250251 * @param {number } flags
252+ * @param {boolean } is_inert
251253 * @param {(value: V, index: number) => any } get_key
252254 * @returns {void }
253255 */
254- function reconcile ( array , state , anchor , render_fn , flags , get_key ) {
256+ function reconcile ( array , state , anchor , render_fn , flags , is_inert , get_key ) {
255257 var is_animated = ( flags & EACH_IS_ANIMATED ) !== 0 ;
256258 var should_update = ( flags & ( EACH_ITEM_REACTIVE | EACH_INDEX_REACTIVE ) ) !== 0 ;
257259
@@ -390,9 +392,9 @@ function reconcile(array, state, anchor, render_fn, flags, get_key) {
390392 stashed = [ ] ;
391393
392394 while ( current !== null && current . k !== key ) {
393- // If the item has an effect that is already inert, skip over adding it
394- // to our seen Set as the item is already being handled
395- if ( ( current . e . f & INERT ) === 0 ) {
395+ // If the each block isn't inert and an item has an effect that is already inert,
396+ // skip over adding it to our seen Set as the item is already being handled
397+ if ( is_inert || ( current . e . f & INERT ) === 0 ) {
396398 ( seen ??= new Set ( ) ) . add ( current ) ;
397399 }
398400 stashed . push ( current ) ;
@@ -415,8 +417,8 @@ function reconcile(array, state, anchor, render_fn, flags, get_key) {
415417 var to_destroy = seen === undefined ? [ ] : array_from ( seen ) ;
416418
417419 while ( current !== null ) {
418- // Inert effects are currently outroing and will be removed once the transition is finished
419- if ( ( current . e . f & INERT ) === 0 ) {
420+ // If the each block isn't inert, then inert effects are currently outroing and will be removed once the transition is finished
421+ if ( is_inert || ( current . e . f & INERT ) === 0 ) {
420422 to_destroy . push ( current ) ;
421423 }
422424 current = current . next ;
0 commit comments