@ -68,7 +68,7 @@ import {
hydrate _block _anchor ,
set _current _hydration _fragment
} from './hydration.js' ;
import { array _from , define _property , get _descriptor , get_descriptors , is_array } from './utils.js' ;
import { array _from , define _property , get _descriptor , is_array } from './utils.js' ;
import { is _promise } from '../common.js' ;
import { bind _transition } from './transitions.js' ;
@ -1270,15 +1270,15 @@ function handle_event_propagation(root_element, event) {
}
// composedPath contains list of nodes the event has propagated through.
// We check __ handled_event_a t to skip all nodes below it in case this is a
// parent of the __ handled_event_a t node, which indicates that there's nested
// We check __ roo t to skip all nodes below it in case this is a
// parent of the __ roo t node, which indicates that there's nested
// mounted apps. In this case we don't want to trigger events multiple times.
// We're deliberately not skipping if the index is the same or higher, because
// someone could create an event programmatically and emit it multiple times,
// in which case we want to handle the whole propagation chain properly each time.
let path _idx = 0 ;
// @ts-expect-error is added below
const handled _at = event . _ _ handled_event _a t;
const handled _at = event . _ _ roo t;
if ( handled _at ) {
const at _idx = path . indexOf ( handled _at ) ;
if ( at _idx < path . indexOf ( root _element ) ) {
@ -1317,7 +1317,7 @@ function handle_event_propagation(root_element, event) {
}
// @ts-expect-error is used above
event . _ _ handled_event _a t = root _element ;
event . _ _ roo t = root _element ;
}
/ * *
@ -2078,7 +2078,7 @@ function get_first_element(block) {
/ * *
* @ param { import ( './types.js' ) . EachItemBlock } block
* @ param { any } item
* @ param { import ( './types.js' ) . MaybeSignal < number > } index
* @ param { number } index
* @ param { number } type
* @ returns { void }
* /
@ -2093,7 +2093,6 @@ export function update_each_item_block(block, item, index, type) {
let prev _index = block . index ;
if ( index _is _reactive ) {
prev _index = /** @type {import('./types.js').Signal<number>} */ ( prev _index ) . value ;
index = /** @type {import('./types.js').Signal<number>} */ ( index ) . value ;
}
const items = block . parent . items ;
if ( prev _index !== index && /** @type {number} */ ( index ) < items . length ) {
@ -2263,9 +2262,10 @@ export function each_item_block(item, key, index, render_fn, flags) {
* @ param { null | ( ( item : V ) => string ) } key _fn
* @ param { ( anchor : null , item : V , index : import ( './types.js' ) . MaybeSignal < number > ) => void } render _fn
* @ param { null | ( ( anchor : Node ) => void ) } fallback _fn
* @ param { typeof reconcile _indexed _array | reconcile _tracked _array } reconcile _fn
* @ returns { void }
* /
export function each ( anchor _node , collection , flags , key _fn , render _fn , fallback _fn ) {
function each ( anchor _node , collection , flags , key _fn , render _fn , fallback _fn , reconcile _fn ) {
const is _controlled = ( flags & EACH _IS _CONTROLLED ) !== 0 ;
const block = create _each _block ( flags , anchor _node ) ;
@ -2385,20 +2385,7 @@ export function each(anchor_node, collection, flags, key_fn, render_fn, fallback
const flags = block . flags ;
const is _controlled = ( flags & EACH _IS _CONTROLLED ) !== 0 ;
const anchor _node = block . anchor ;
if ( ( flags & EACH _KEYED ) !== 0 ) {
reconcile _tracked _array (
array ,
block ,
anchor _node ,
is _controlled ,
render _fn ,
keys ,
flags ,
true
) ;
} else {
reconcile _indexed _array ( array , block , anchor _node , is _controlled , render _fn , flags , true ) ;
}
reconcile _fn ( array , block , anchor _node , is _controlled , render _fn , flags , true , keys ) ;
} ,
block ,
true
@ -2420,12 +2407,39 @@ export function each(anchor_node, collection, flags, key_fn, render_fn, fallback
fallback = fallback . prev ;
}
// Clear the array
reconcile _ indexed_array ( [ ] , block , anchor _node , is _controlled , render _fn , flags , false ) ;
reconcile _ fn ( [ ] , block , anchor _node , is _controlled , render _fn , flags , false , keys ) ;
destroy _signal ( /** @type {import('./types.js').EffectSignal} */ ( render ) ) ;
} ) ;
block . effect = each ;
}
/ * *
* @ template V
* @ param { Element | Comment } anchor _node
* @ param { ( ) => V [ ] } collection
* @ param { number } flags
* @ param { null | ( ( item : V ) => string ) } key _fn
* @ param { ( anchor : null , item : V , index : import ( './types.js' ) . MaybeSignal < number > ) => void } render _fn
* @ param { null | ( ( anchor : Node ) => void ) } fallback _fn
* @ returns { void }
* /
export function each _keyed ( anchor _node , collection , flags , key _fn , render _fn , fallback _fn ) {
each ( anchor _node , collection , flags , key _fn , render _fn , fallback _fn , reconcile _tracked _array ) ;
}
/ * *
* @ template V
* @ param { Element | Comment } anchor _node
* @ param { ( ) => V [ ] } collection
* @ param { number } flags
* @ param { ( anchor : null , item : V , index : import ( './types.js' ) . MaybeSignal < number > ) => void } render _fn
* @ param { null | ( ( anchor : Node ) => void ) } fallback _fn
* @ returns { void }
* /
export function each _indexed ( anchor _node , collection , flags , render _fn , fallback _fn ) {
each ( anchor _node , collection , flags , null , render _fn , fallback _fn , reconcile _indexed _array ) ;
}
/ * *
* @ param { Element | Text | Comment } anchor
* @ param { boolean } is _html