* @template V * @param {Map<any, EachItem>} items * @param {Node} anchor * @param {V} value * @param {unknown} key * @param {number} index * @param {(anchor: Node, item: V | Source<V>, index: number | Value<number>, collection: () => V[]) => void} render_fn * @param {number} flags * @param {
(items, anchor, value, key, index, render_fn, flags, get_collection)
| 666 | * @returns {EachItem} |
| 667 | */ |
| 668 | function create_item(items, anchor, value, key, index, render_fn, flags, get_collection) { |
| 669 | var v = |
| 670 | (flags & EACH_ITEM_REACTIVE) !== 0 |
| 671 | ? (flags & EACH_ITEM_IMMUTABLE) === 0 |
| 672 | ? mutable_source(value, false, false) |
| 673 | : source(value) |
| 674 | : null; |
| 675 | |
| 676 | var i = (flags & EACH_INDEX_REACTIVE) !== 0 ? source(index) : null; |
| 677 | |
| 678 | if (DEV && v) { |
| 679 | // For tracing purposes, we need to link the source signal we create with the |
| 680 | // collection + index so that tracing works as intended |
| 681 | v.trace = () => { |
| 682 | // eslint-disable-next-line @typescript-eslint/no-unused-expressions |
| 683 | get_collection()[i?.v ?? index]; |
| 684 | }; |
| 685 | } |
| 686 | |
| 687 | return { |
| 688 | v, |
| 689 | i, |
| 690 | e: branch(() => { |
| 691 | render_fn(anchor, v ?? value, i ?? index, get_collection); |
| 692 | |
| 693 | return () => { |
| 694 | items.delete(key); |
| 695 | }; |
| 696 | }) |
| 697 | }; |
| 698 | } |
| 699 | |
| 700 | /** |
| 701 | * @param {Effect} effect |
no test coverage detected