native-document 1.0.77 → 1.0.79

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.
Files changed (126) hide show
  1. package/dist/native-document.components.min.js +146 -120
  2. package/dist/native-document.dev.js +171 -125
  3. package/dist/native-document.dev.js.map +1 -1
  4. package/dist/native-document.devtools.min.js +1 -1
  5. package/dist/native-document.min.js +1 -1
  6. package/package.json +1 -1
  7. package/rollup.config.js +0 -16
  8. package/src/components/$traits/HasItems.js +1 -1
  9. package/src/components/accordion/Accordion.js +2 -2
  10. package/src/components/accordion/AccordionItem.js +2 -2
  11. package/src/components/alert/Alert.js +2 -2
  12. package/src/components/avatar/Avatar.js +2 -2
  13. package/src/components/badge/Badge.js +2 -2
  14. package/src/components/breadcrumb/BreadCrumb.js +2 -2
  15. package/src/components/button/Button.js +2 -2
  16. package/src/components/card/Card.js +1 -1
  17. package/src/components/context-menu/ContextMenu.js +2 -2
  18. package/src/components/context-menu/ContextMenuGroup.js +1 -1
  19. package/src/components/context-menu/ContextMenuItem.js +1 -1
  20. package/src/components/divider/Divider.js +1 -1
  21. package/src/components/dropdown/Dropdown.js +2 -2
  22. package/src/components/dropdown/DropdownDivider.js +1 -1
  23. package/src/components/dropdown/DropdownGroup.js +1 -1
  24. package/src/components/dropdown/DropdownItem.js +1 -1
  25. package/src/components/dropdown/DropdownTrigger.js +1 -1
  26. package/src/components/form/FormControl.js +5 -5
  27. package/src/components/form/field/DefaultRender.js +2 -2
  28. package/src/components/form/field/Field.js +4 -4
  29. package/src/components/form/field/FieldCollection.js +5 -5
  30. package/src/components/form/field/types/CheckboxField.js +1 -1
  31. package/src/components/form/field/types/ColorField.js +1 -1
  32. package/src/components/form/field/types/DateField.js +1 -1
  33. package/src/components/form/field/types/EmailField.js +1 -1
  34. package/src/components/form/field/types/FileField.js +1 -1
  35. package/src/components/form/field/types/ImageField.js +1 -1
  36. package/src/components/form/field/types/NumberField.js +1 -1
  37. package/src/components/form/field/types/PasswordField.js +1 -1
  38. package/src/components/form/field/types/RadioField.js +1 -1
  39. package/src/components/form/field/types/StringField.js +1 -1
  40. package/src/components/form/field/types/TelField.js +1 -1
  41. package/src/components/form/field/types/TimeField.js +1 -1
  42. package/src/components/form/field/types/UrlField.js +1 -1
  43. package/src/components/form/validation/Validation.js +1 -1
  44. package/src/components/list/List.js +4 -4
  45. package/src/components/list/ListGroup.js +2 -2
  46. package/src/components/list/ListItem.js +2 -2
  47. package/src/components/menu/Menu.js +3 -3
  48. package/src/components/menu/MenuDivider.js +1 -1
  49. package/src/components/menu/MenuGroup.js +2 -2
  50. package/src/components/menu/MenuItem.js +2 -2
  51. package/src/components/modal/Modal.js +2 -2
  52. package/src/components/pagination/Pagination.js +2 -2
  53. package/src/components/popover/Popover.js +2 -2
  54. package/src/components/popover/PopoverFooter.js +1 -1
  55. package/src/components/popover/PopoverHeader.js +1 -1
  56. package/src/components/progress/Progress.js +3 -3
  57. package/src/components/slider/Slider.js +2 -2
  58. package/src/components/splitter/Splitter.js +3 -4
  59. package/src/components/splitter/SplitterPanel.js +1 -1
  60. package/src/components/stepper/Stepper.js +3 -3
  61. package/src/components/stepper/StepperStep.js +2 -2
  62. package/src/components/switch/Switch.js +2 -2
  63. package/src/components/table/ColumnGroup.js +1 -1
  64. package/src/components/table/DataTable.js +1 -1
  65. package/src/components/table/SimpleTable.js +1 -1
  66. package/src/components/tabs/Tabs.js +2 -2
  67. package/src/components/toast/Toast.js +2 -2
  68. package/src/components/tooltip/prototypes.js +1 -1
  69. package/src/core/data/MemoryManager.js +1 -2
  70. package/src/core/data/Observable.js +1 -1
  71. package/src/core/data/ObservableArray.js +4 -4
  72. package/src/core/data/ObservableItem.js +5 -5
  73. package/src/core/data/observable-helpers/array.js +2 -2
  74. package/src/core/data/observable-helpers/batch.js +2 -2
  75. package/src/core/data/observable-helpers/computed.js +6 -6
  76. package/src/core/data/observable-helpers/object.js +2 -2
  77. package/src/core/elements/anchor.js +3 -3
  78. package/src/core/elements/content-formatter.js +1 -1
  79. package/src/core/elements/control/for-each-array.js +5 -6
  80. package/src/core/elements/control/for-each.js +7 -7
  81. package/src/core/elements/control/show-if.js +5 -5
  82. package/src/core/elements/control/show-when.js +2 -2
  83. package/src/core/elements/control/switch.js +4 -4
  84. package/src/core/elements/description-list.js +1 -1
  85. package/src/core/elements/form.js +1 -1
  86. package/src/core/elements/html5-semantics.js +1 -1
  87. package/src/core/elements/img.js +3 -3
  88. package/src/core/elements/index.js +1 -1
  89. package/src/core/elements/interactive.js +1 -1
  90. package/src/core/elements/list.js +1 -1
  91. package/src/core/elements/medias.js +1 -1
  92. package/src/core/elements/meta-data.js +1 -1
  93. package/src/core/elements/table.js +1 -1
  94. package/src/core/utils/EventEmitter.js +1 -1
  95. package/src/core/utils/args-types.js +2 -2
  96. package/src/core/utils/filters/standard.js +1 -1
  97. package/src/core/utils/filters/utils.js +1 -1
  98. package/src/core/utils/prototypes.js +2 -2
  99. package/src/core/utils/validator.js +5 -5
  100. package/src/core/wrappers/AttributesWrapper.js +3 -3
  101. package/src/core/wrappers/DocumentObserver.js +0 -1
  102. package/src/core/wrappers/ElementCreator.js +3 -3
  103. package/src/core/wrappers/HtmlElementWrapper.js +2 -2
  104. package/src/core/wrappers/NDElement.js +3 -3
  105. package/src/core/wrappers/NdPrototype.js +1 -1
  106. package/src/core/wrappers/SingletonView.js +1 -1
  107. package/src/core/wrappers/TemplateCloner.js +1 -2
  108. package/src/core/wrappers/prototypes/attributes-extensions.js +4 -4
  109. package/src/core/wrappers/prototypes/bind-class-extensions.js +4 -4
  110. package/src/core/wrappers/prototypes/nd-element-extensions.js +6 -6
  111. package/src/devtools/app/App.js +2 -2
  112. package/src/devtools/hrm/ComponentRegistry.js +2 -2
  113. package/src/devtools/plugin.js +1 -1
  114. package/src/devtools/widget/DevToolsWidget.js +2 -2
  115. package/src/router/Route.js +1 -1
  116. package/src/router/RouteGroupHelper.js +1 -1
  117. package/src/router/Router.js +4 -4
  118. package/src/router/RouterComponent.js +1 -1
  119. package/src/router/link.js +4 -4
  120. package/src/router/modes/HistoryRouter.js +1 -1
  121. package/types/control-flow.d.ts +0 -1
  122. package/types/filters/dates.d.ts +1 -1
  123. package/types/filters/types.d.ts +1 -1
  124. package/utils.js +3 -3
  125. package/jsconfig.json +0 -15
  126. /package/src/{core → router}/errors/RouterError.js +0 -0
@@ -259,15 +259,18 @@ var NativeDocument = (function (exports) {
259
259
  * @returns {*}
260
260
  */
261
261
  const getKey = (item, defaultKey, key) => {
262
- if(Validator.isFunction(key)) return key(item, defaultKey);
263
- if(Validator.isObservable(item)) {
264
- const val = item.val();
265
- return (val && key) ? val[key] : defaultKey;
262
+ if (Validator.isString(key)) {
263
+ const val = Validator.isObservable(item) ? item.val() : item;
264
+ const result = val?.[key];
265
+ return Validator.isObservable(result) ? result.val() : (result ?? defaultKey);
266
266
  }
267
- if(!Validator.isObject(item)) {
268
- return item;
267
+
268
+ if (Validator.isFunction(key)) {
269
+ return key(item, defaultKey);
269
270
  }
270
- return item[key]?.val?.() ?? item[key] ?? defaultKey;
271
+
272
+ const val = Validator.isObservable(item) ? item.val() : item;
273
+ return val ?? defaultKey;
271
274
  };
272
275
 
273
276
  const trim = function(str, char) {
@@ -1050,6 +1053,7 @@ var NativeDocument = (function (exports) {
1050
1053
  };
1051
1054
  {
1052
1055
  Validator.validateAttributes = function(attributes) {
1056
+ console.log('AttributesWrapper', attributes);
1053
1057
  if (!attributes || typeof attributes !== 'object') {
1054
1058
  return attributes;
1055
1059
  }
@@ -1215,7 +1219,38 @@ var NativeDocument = (function (exports) {
1215
1219
  return anchor;
1216
1220
  }
1217
1221
 
1218
- const BOOLEAN_ATTRIBUTES = ['checked', 'selected', 'disabled', 'readonly', 'required', 'autofocus', 'multiple', 'autocomplete', 'hidden', 'contenteditable', 'spellcheck', 'translate', 'draggable', 'async', 'defer', 'autoplay', 'controls', 'loop', 'muted', 'download', 'reversed', 'open', 'default', 'formnovalidate', 'novalidate', 'scoped', 'itemscope', 'allowfullscreen', 'allowpaymentrequest', 'playsinline'];
1222
+ const BOOLEAN_ATTRIBUTES = new Set([
1223
+ 'checked',
1224
+ 'selected',
1225
+ 'disabled',
1226
+ 'readonly',
1227
+ 'required',
1228
+ 'autofocus',
1229
+ 'multiple',
1230
+ 'autocomplete',
1231
+ 'hidden',
1232
+ 'contenteditable',
1233
+ 'spellcheck',
1234
+ 'translate',
1235
+ 'draggable',
1236
+ 'async',
1237
+ 'defer',
1238
+ 'autoplay',
1239
+ 'controls',
1240
+ 'loop',
1241
+ 'muted',
1242
+ 'download',
1243
+ 'reversed',
1244
+ 'open',
1245
+ 'default',
1246
+ 'formnovalidate',
1247
+ 'novalidate',
1248
+ 'scoped',
1249
+ 'itemscope',
1250
+ 'allowfullscreen',
1251
+ 'allowpaymentrequest',
1252
+ 'playsinline'
1253
+ ]);
1219
1254
 
1220
1255
  /**
1221
1256
  *
@@ -1404,6 +1439,12 @@ var NativeDocument = (function (exports) {
1404
1439
  }
1405
1440
  }
1406
1441
 
1442
+ const NdBindings = {
1443
+ class: (element, value) => bindClassAttribute(element, value),
1444
+ style: (element, value) => bindStyleAttribute(element, value),
1445
+ };
1446
+
1447
+
1407
1448
  /**
1408
1449
  *
1409
1450
  * @param {HTMLElement} element
@@ -1419,41 +1460,27 @@ var NativeDocument = (function (exports) {
1419
1460
 
1420
1461
  for(let key in attributes) {
1421
1462
  const attributeName = key.toLowerCase();
1422
- let value = attributes[attributeName];
1423
- if(value === null || value === undefined) {
1463
+ let value = attributes[key];
1464
+ if(value == null) {
1424
1465
  continue;
1425
1466
  }
1426
1467
  if(value.handleNdAttribute) {
1427
1468
  value.handleNdAttribute(element, attributeName, value);
1428
1469
  continue;
1429
1470
  }
1430
- if(Validator.isString(value)) {
1431
- element.setAttribute(attributeName, value);
1432
- return;
1433
- }
1434
- if(attributeName === 'class' && Validator.isObject(value)) {
1435
- bindClassAttribute(element, value);
1436
- continue;
1437
- }
1438
- if(attributeName === 'style' && Validator.isObject(value)) {
1439
- bindStyleAttribute(element, value);
1440
- continue;
1471
+ if(typeof value === 'object') {
1472
+ const binding = NdBindings[attributeName];
1473
+ if(binding) {
1474
+ binding(element, value);
1475
+ continue;
1476
+ }
1441
1477
  }
1442
- if(BOOLEAN_ATTRIBUTES.includes(attributeName)) {
1478
+ if(BOOLEAN_ATTRIBUTES.has(attributeName)) {
1443
1479
  bindBooleanAttribute(element, attributeName, value);
1444
1480
  continue;
1445
1481
  }
1446
- if(Validator.isObservable(value)) {
1447
- bindAttributeWithObservable(element, attributeName, value);
1448
- continue;
1449
- }
1450
- if(value.$hydrate) {
1451
- value.$hydrate(element, attributeName);
1452
- continue;
1453
- }
1454
1482
 
1455
1483
  element.setAttribute(attributeName, value);
1456
-
1457
1484
  }
1458
1485
  return element;
1459
1486
  }
@@ -1514,8 +1541,16 @@ var NativeDocument = (function (exports) {
1514
1541
  element.setAttribute(attributeName, this);
1515
1542
  };
1516
1543
 
1544
+ Number.prototype.handleNdAttribute = function(element, attributeName) {
1545
+ element.setAttribute(attributeName, this);
1546
+ };
1547
+
1548
+ Boolean.prototype.handleNdAttribute = function(element, attrName) {
1549
+ bindBooleanAttribute(element, attrName, this);
1550
+ };
1551
+
1517
1552
  ObservableItem.prototype.handleNdAttribute = function(element, attributeName) {
1518
- if(BOOLEAN_ATTRIBUTES.includes(attributeName)) {
1553
+ if(BOOLEAN_ATTRIBUTES.has(attributeName)) {
1519
1554
  bindBooleanAttribute(element, attributeName, this);
1520
1555
  return;
1521
1556
  }
@@ -1605,22 +1640,14 @@ var NativeDocument = (function (exports) {
1605
1640
  PluginsManager.emit('AfterProcessChildren', parent);
1606
1641
  },
1607
1642
  getChild(child) {
1608
- if(child == null) {
1609
- return null;
1610
- }
1611
- if(child.toNdElement) {
1612
- do {
1613
- child = child.toNdElement();
1614
- if(Validator.isElement(child)) {
1615
- return child;
1616
- }
1617
- if(child == null) {
1618
- return null;
1619
- }
1620
- } while (child.toNdElement);
1643
+ while (child?.toNdElement) {
1644
+ child = child.toNdElement();
1645
+
1646
+ if (Validator.isElement(child)) return child;
1647
+ if (!child) return null;
1621
1648
  }
1622
1649
 
1623
- return ElementCreator.createStaticTextNode(null, child);
1650
+ return child ? ElementCreator.createStaticTextNode(null, child) : null;
1624
1651
  },
1625
1652
  /**
1626
1653
  *
@@ -2088,7 +2115,7 @@ var NativeDocument = (function (exports) {
2088
2115
  if(bindDingData.attributes) {
2089
2116
  attributes = {};
2090
2117
  for (const attr in bindDingData.attributes) {
2091
- attributes[attr] = bindDingData.attributes[attr](...data);
2118
+ attributes[attr] = bindDingData.attributes[attr].apply(null, data);
2092
2119
  }
2093
2120
  }
2094
2121
 
@@ -2096,7 +2123,7 @@ var NativeDocument = (function (exports) {
2096
2123
  attributes = attributes || {};
2097
2124
  attributes.class = {};
2098
2125
  for (const className in bindDingData.classes) {
2099
- attributes.class[className] = bindDingData.classes[className](...data);
2126
+ attributes.class[className] = bindDingData.classes[className].apply(null, data);
2100
2127
  }
2101
2128
  }
2102
2129
 
@@ -2104,7 +2131,7 @@ var NativeDocument = (function (exports) {
2104
2131
  attributes = attributes || {};
2105
2132
  attributes.style = {};
2106
2133
  for (const property in bindDingData.styles) {
2107
- attributes.style[property] = bindDingData.styles[property](...data);
2134
+ attributes.style[property] = bindDingData.styles[property].apply(null, data);
2108
2135
  }
2109
2136
  }
2110
2137
 
@@ -2116,6 +2143,14 @@ var NativeDocument = (function (exports) {
2116
2143
  return null;
2117
2144
  };
2118
2145
 
2146
+ const findByPath = (root, path) => {
2147
+ let target = root;
2148
+ for (let i = 0, len = path.length; i < len; i++) {
2149
+ target = target.childNodes[path[i]];
2150
+ }
2151
+ return target;
2152
+ };
2153
+
2119
2154
  const $hydrateFn = function(hydrateFunction, targetType, element, property) {
2120
2155
  if(!cloneBindingsDataCache.has(element)) {
2121
2156
  // { classes, styles, attributes, value, attach }
@@ -2136,7 +2171,7 @@ var NativeDocument = (function (exports) {
2136
2171
  }
2137
2172
  for(const methodName in bindDingData.attach) {
2138
2173
  node.nd[methodName](function(...args) {
2139
- bindDingData.attach[methodName].call(this, ...[...args, ...data]);
2174
+ bindDingData.attach[methodName].apply(this, [...args, ...data]);
2140
2175
  });
2141
2176
  }
2142
2177
  };
@@ -2145,44 +2180,78 @@ var NativeDocument = (function (exports) {
2145
2180
  let $node = null;
2146
2181
  let $hasBindingData = false;
2147
2182
 
2148
- const clone = (node, data) => {
2183
+ const $bindingPaths = [];
2184
+
2185
+ const clone = (node, data, path) => {
2149
2186
  const bindDingData = cloneBindingsDataCache.get(node);
2150
2187
  if(node.nodeType === 3) {
2151
2188
  if(bindDingData && bindDingData.value) {
2189
+ $bindingPaths.push({
2190
+ path: [...path],
2191
+ fn: (data, targetNode, currentRoot) => {
2192
+ const newNode = bindDingData.value(data);
2193
+ targetNode.replaceWith(newNode);
2194
+ if (targetNode === currentRoot) {
2195
+ return newNode;
2196
+ }
2197
+ return null;
2198
+ }
2199
+ });
2152
2200
  return bindDingData.value(data);
2153
2201
  }
2154
2202
  return node.cloneNode(true);
2155
2203
  }
2156
2204
  const nodeCloned = node.cloneNode(node.fullCloneNode);
2205
+ if(node.fullCloneNode) {
2206
+ return nodeCloned;
2207
+ }
2157
2208
  if(bindDingData) {
2158
2209
  bindAttributes(nodeCloned, bindDingData, data);
2159
2210
  bindAttachMethods(nodeCloned, bindDingData, data);
2160
- }
2161
- if(node.fullCloneNode) {
2162
- return nodeCloned;
2211
+ $bindingPaths.push({
2212
+ path: [...path],
2213
+ fn: (data, targetNode) => {
2214
+ bindAttributes(targetNode, bindDingData, data);
2215
+ bindAttachMethods(targetNode, bindDingData, data);
2216
+ }
2217
+ });
2163
2218
  }
2164
2219
  const childNodes = node.childNodes;
2165
2220
  for(let i = 0, length = childNodes.length; i < length; i++) {
2166
2221
  const childNode = childNodes[i];
2167
- const childNodeCloned = clone(childNode, data);
2222
+ path.push(i);
2223
+ const childNodeCloned = clone(childNode, data, path);
2224
+ path.pop();
2168
2225
  nodeCloned.appendChild(childNodeCloned);
2169
2226
  }
2170
2227
  return nodeCloned;
2171
2228
  };
2172
2229
 
2173
- this.clone = (data) => {
2174
- if(!$node) {
2175
- $node = $fn(this);
2176
- if(!$hasBindingData) {
2177
- const nodeCloned = $node.cloneNode(true);
2178
- nodeCloned.fullCloneNode = true;
2179
- return nodeCloned;
2230
+ const cloneWithBindingPaths = (data) => {
2231
+ let root = $node.cloneNode(true);
2232
+
2233
+ for (let i = 0, len = $bindingPaths.length; i < len; i++) {
2234
+ const binding = $bindingPaths[i];
2235
+ const target = findByPath(root, binding.path);
2236
+ const newRoot = binding.fn(data, target, root);
2237
+ if(newRoot) {
2238
+ root = newRoot;
2180
2239
  }
2181
2240
  }
2241
+
2242
+ return root;
2243
+ };
2244
+
2245
+ this.clone = (data) => {
2246
+ $node = $fn(this);
2182
2247
  if(!$hasBindingData) {
2248
+ this.clone = () => $node.cloneNode(true);
2183
2249
  return $node.cloneNode(true);
2184
2250
  }
2185
- return clone($node, data);
2251
+
2252
+ const firstClone = clone($node, data, []);
2253
+ this.clone = cloneWithBindingPaths;
2254
+ return firstClone;
2186
2255
  };
2187
2256
 
2188
2257
 
@@ -2835,6 +2904,9 @@ var NativeDocument = (function (exports) {
2835
2904
  });
2836
2905
 
2837
2906
  ObservableArray.prototype.clear = function() {
2907
+ if(this.$currentValue.length === 0) {
2908
+ return;
2909
+ }
2838
2910
  this.$currentValue.length = 0;
2839
2911
  this.trigger({ action: 'clear' });
2840
2912
  return true;
@@ -3444,7 +3516,7 @@ var NativeDocument = (function (exports) {
3444
3516
  return element;
3445
3517
  }
3446
3518
 
3447
- function ForEachArray(data, callback, key, configs = {}) {
3519
+ function ForEachArray(data, callback, configs = {}) {
3448
3520
  const element = Anchor('ForEach Array');
3449
3521
  const blockEnd = element.endElement();
3450
3522
  const blockStart = element.startElement();
@@ -3453,23 +3525,14 @@ var NativeDocument = (function (exports) {
3453
3525
  let lastNumberOfItems = 0;
3454
3526
  const isIndexRequired = callback.length >= 2;
3455
3527
 
3456
- const keysCache = new WeakMap();
3457
-
3458
- const clear = () => {
3528
+ const clear = (items) => {
3459
3529
  element.removeChildren();
3460
- cleanCache();
3530
+ cleanCache(items);
3461
3531
  lastNumberOfItems = 0;
3462
3532
  };
3463
3533
 
3464
- const getItemKey = (item, indexKey) => {
3465
- if(keysCache.has(item)) {
3466
- return keysCache.get(item);
3467
- }
3468
- return getKey(item, indexKey, key);
3469
- };
3470
-
3471
3534
  const getItemChild = (item) => {
3472
- return getChildByKey(getItemKey(item));
3535
+ return cache.get(item)?.child;
3473
3536
  };
3474
3537
 
3475
3538
  const updateIndexObservers = (items, startFrom = 0) => {
@@ -3478,16 +3541,17 @@ var NativeDocument = (function (exports) {
3478
3541
  }
3479
3542
  let index = startFrom;
3480
3543
  for(let i = startFrom, length = items?.length; i < length; i++) {
3481
- const cacheItem = cache.get(getItemKey(items[i], i));
3544
+ const cacheItem = cache.get(items[i]);
3482
3545
  if(!cacheItem) {
3483
3546
  continue;
3484
3547
  }
3485
- cacheItem.indexObserver?.deref()?.set(index);
3548
+ cacheItem.indexObserver?.set(index);
3486
3549
  index++;
3487
3550
  }
3488
3551
  };
3489
3552
 
3490
- const removeCacheItem = (cacheItem, removeChild = true) => {
3553
+ const removeCacheItem = (item, removeChild = true) => {
3554
+ const cacheItem = cache.get(item);
3491
3555
  if(!cacheItem) {
3492
3556
  return;
3493
3557
  }
@@ -3496,14 +3560,10 @@ var NativeDocument = (function (exports) {
3496
3560
  child?.remove();
3497
3561
  cache.delete(cacheItem.keyId);
3498
3562
  }
3499
- cacheItem.indexObserver?.deref()?.cleanup();
3563
+ cacheItem.indexObserver?.cleanup();
3500
3564
  };
3501
3565
 
3502
- const removeCacheItemByKey = (keyId, removeChild = true) => {
3503
- removeCacheItem(cache.get(keyId), removeChild);
3504
- };
3505
-
3506
- const cleanCache = () => {
3566
+ const cleanCache = (items) => {
3507
3567
  if(configs.shouldKeepItemsInCache) {
3508
3568
  return;
3509
3569
  }
@@ -3511,53 +3571,41 @@ var NativeDocument = (function (exports) {
3511
3571
  cache.clear();
3512
3572
  return;
3513
3573
  }
3514
- for (const [keyId, cacheItem] of cache.entries()) {
3515
- removeCacheItem(cacheItem, false);
3574
+ for (const [itemAsKey, _] of cache.entries()) {
3575
+ if(items && items.contains(itemAsKey)) {
3576
+ continue;
3577
+ }
3578
+ removeCacheItem(itemAsKey, false);
3516
3579
  }
3517
3580
  cache.clear();
3518
3581
  };
3519
3582
 
3520
3583
  const buildItem = (item, indexKey) => {
3521
- const keyId = getItemKey(item, indexKey);
3522
-
3523
- if(cache.has(keyId)) {
3524
- const cacheItem = cache.get(keyId);
3525
- cacheItem.indexObserver?.deref()?.set(indexKey);
3584
+ const cacheItem = cache.get(item);
3585
+ if(cacheItem) {
3586
+ cacheItem.indexObserver?.set(indexKey);
3526
3587
  const child = cacheItem.child;
3527
3588
  if(child) {
3528
3589
  return child;
3529
3590
  }
3530
- cache.delete(keyId);
3591
+ cache.delete(item);
3531
3592
  }
3532
3593
 
3533
3594
  const indexObserver = isIndexRequired ? Observable(indexKey) : null;
3534
3595
  let child = ElementCreator.getChild(callback(item, indexObserver));
3535
- if(!child) {
3536
- throw new NativeDocumentError("ForEachArray child can't be null or undefined!");
3537
- }
3538
- cache.set(keyId, {
3539
- keyId,
3540
- child: child,
3541
- indexObserver: (indexObserver ? new WeakRef(indexObserver) : null)
3542
- });
3543
- keysCache.set(item, keyId);
3544
- return child;
3545
- };
3546
- const getChildByKey = function(keyId) {
3547
- const cacheItem = cache.get(keyId);
3548
- if(!cacheItem) {
3549
- return null;
3550
- }
3551
- const child = cacheItem.child;
3552
- if(!child) {
3553
- removeCacheItem(cacheItem, false);
3554
- return null;
3596
+ if(child) {
3597
+ cache.set(item, {
3598
+ child,
3599
+ indexObserver: (indexObserver ? new WeakRef(indexObserver) : null)
3600
+ });
3601
+ return child;
3555
3602
  }
3556
- return child;
3603
+
3604
+ throw new NativeDocumentError("ForEachArray child can't be null or undefined!");
3557
3605
  };
3558
3606
 
3559
- const removeByKey = function(keyId, fragment) {
3560
- const cacheItem = cache.get(keyId);
3607
+ const removeByItem = function(item, fragment) {
3608
+ const cacheItem = cache.get(item);
3561
3609
  if(!cacheItem) {
3562
3610
  return null;
3563
3611
  }
@@ -3583,11 +3631,10 @@ var NativeDocument = (function (exports) {
3583
3631
  return fragment;
3584
3632
  },
3585
3633
  add(items, delay = 2) {
3586
- const fragment = Actions.toFragment(items);
3587
- element.appendElement(fragment);
3634
+ element.appendElement(Actions.toFragment(items));
3588
3635
  },
3589
3636
  replace(items) {
3590
- clear();
3637
+ clear(items);
3591
3638
  Actions.add(items);
3592
3639
  },
3593
3640
  reOrder(items) {
@@ -3603,7 +3650,7 @@ var NativeDocument = (function (exports) {
3603
3650
  element.appendElement(fragment, blockEnd);
3604
3651
  },
3605
3652
  removeOne(element, index) {
3606
- removeCacheItemByKey(getItemKey(element, index), true);
3653
+ removeCacheItem(element, true);
3607
3654
  },
3608
3655
  clear,
3609
3656
  merge(items) {
@@ -3637,16 +3684,15 @@ var NativeDocument = (function (exports) {
3637
3684
  const garbageFragment = document.createDocumentFragment();
3638
3685
 
3639
3686
  if(deleted.length > 0) {
3640
- let firstKey = getItemKey(deleted[0], start);
3687
+ let firstItem = deleted[0];
3641
3688
  if(deleted.length === 1) {
3642
- removeByKey(firstKey, garbageFragment);
3689
+ removeByItem(firstItem, garbageFragment);
3643
3690
  } else if(deleted.length > 1) {
3644
- const firstChildRemoved = getChildByKey(firstKey);
3691
+ const firstChildRemoved = getItemChild(deleted[0]);
3645
3692
  elementBeforeFirst = firstChildRemoved?.previousSibling;
3646
3693
 
3647
3694
  for(let i = 0; i < deleted.length; i++) {
3648
- const keyId = getItemKey(deleted[i], start + i);
3649
- removeByKey(keyId, garbageFragment);
3695
+ firstItem(deleted[i], garbageFragment);
3650
3696
  }
3651
3697
  }
3652
3698
  } else {