ripple 0.2.99 → 0.2.100

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ripple is an elegant TypeScript UI framework",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.2.99",
6
+ "version": "0.2.100",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index-client.js",
9
9
  "main": "src/runtime/index-client.js",
@@ -69,14 +69,15 @@ function move(block, anchor) {
69
69
  /**
70
70
  * @template V
71
71
  * @param {V[] | Iterable<V>} collection
72
+ * @param {boolean} clone
72
73
  * @returns {V[]}
73
74
  */
74
- function collection_to_array(collection) {
75
+ function collection_to_array(collection, clone) {
75
76
  var array = is_array(collection) ? collection : collection == null ? [] : array_from(collection);
76
77
 
77
78
  // If we are working with a tracked array, then we need to get a copy of
78
79
  // the elements, as the array itself is proxied, and not useful in diffing
79
- if (TRACKED_ARRAY in array) {
80
+ if (clone || TRACKED_ARRAY in array) {
80
81
  array = array_from(array);
81
82
  }
82
83
 
@@ -106,7 +107,7 @@ export function for_block(node, get_collection, render_fn, flags, get_key) {
106
107
  render(() => {
107
108
  var block = /** @type {Block} */ (active_block);
108
109
  var collection = get_collection();
109
- var array = collection_to_array(collection);
110
+ var array = collection_to_array(collection, is_keyed);
110
111
  if (is_keyed) {
111
112
  array = keyed(block, array, /** @type {(item: V) => K} */ (get_key));
112
113
  }
@@ -473,12 +474,11 @@ function lis_algorithm(arr) {
473
474
  * @template V
474
475
  * @template K
475
476
  * @param {Block} block
476
- * @param {V[] | Iterable<V>} collection
477
+ * @param {V[]} b_array
477
478
  * @param {(item: V) => K} key_fn
478
479
  * @returns {V[]}
479
480
  */
480
- function keyed(block, collection, key_fn) {
481
- var b_array = collection_to_array(collection);
481
+ function keyed(block, b_array, key_fn) {
482
482
  var b_keys = b_array.map(key_fn);
483
483
 
484
484
  // We only need to do this in DEV
@@ -491,11 +491,10 @@ function keyed(block, collection, key_fn) {
491
491
 
492
492
  if (state === null) {
493
493
  // Make a clone of it so we don't mutate the original thereafter
494
- return b_array.slice();
494
+ return b_array;
495
495
  }
496
496
 
497
497
  var a_array = state.array;
498
- var a_blocks = state.blocks;
499
498
  var a_keys = a_array.map(key_fn);
500
499
  var a = new Map();
501
500