@zoijs/core 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/core/each.js CHANGED
@@ -1,24 +1,24 @@
1
- // each() — keyed list rendering (Milestone 3).
2
- //
3
- // Returns a small marker object that the renderer recognizes in a text slot and
4
- // turns into a keyed list binding. Keeping this factory tiny (and separate from
5
- // the renderer) avoids a circular import — the renderer just checks the marker.
6
- //
7
- // ${each(
8
- // () => todos.get(), // items: a reactive function (or a plain array)
9
- // todo => todo.id, // keyFn: a stable unique key per item
10
- // todo => html`<li>...</li>` // renderFn: builds DOM for one item
11
- // )}
12
- //
13
- // When the array changes, items with matching keys reuse their DOM nodes (moved
14
- // if reordered); new keys are inserted; removed keys are disposed and removed.
15
-
16
- /**
17
- * @param {Function|Array} items a function returning the array, or an array
18
- * @param {Function} keyFn item -> unique key
19
- * @param {Function} renderFn item -> html() result
20
- * @returns {{ __zoijsEach: true, items: any, keyFn: Function, renderFn: Function }}
21
- */
22
- export function each(items, keyFn, renderFn) {
23
- return { __zoijsEach: true, items, keyFn, renderFn };
24
- }
1
+ // each() — keyed list rendering (Milestone 3).
2
+ //
3
+ // Returns a small marker object that the renderer recognizes in a text slot and
4
+ // turns into a keyed list binding. Keeping this factory tiny (and separate from
5
+ // the renderer) avoids a circular import — the renderer just checks the marker.
6
+ //
7
+ // ${each(
8
+ // () => todos.get(), // items: a reactive function (or a plain array)
9
+ // todo => todo.id, // keyFn: a stable unique key per item
10
+ // todo => html`<li>...</li>` // renderFn: builds DOM for one item
11
+ // )}
12
+ //
13
+ // When the array changes, items with matching keys reuse their DOM nodes (moved
14
+ // if reordered); new keys are inserted; removed keys are disposed and removed.
15
+
16
+ /**
17
+ * @param {Function|Array} items a function returning the array, or an array
18
+ * @param {Function} keyFn item -> unique key
19
+ * @param {Function} renderFn item -> html() result
20
+ * @returns {{ __zoijsEach: true, items: any, keyFn: Function, renderFn: Function }}
21
+ */
22
+ export function each(items, keyFn, renderFn) {
23
+ return { __zoijsEach: true, items, keyFn, renderFn };
24
+ }