j-templates 7.0.103 → 7.0.105

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/Node/vNode.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.vNode = void 0;
4
+ const array_1 = require("../_not_used/array");
4
5
  const Store_1 = require("../Store");
5
6
  const observableScope_1 = require("../Store/Tree/observableScope");
6
7
  const emitter_1 = require("../Utils/emitter");
@@ -204,29 +205,18 @@ function ToArray(result) {
204
205
  return result;
205
206
  return [result];
206
207
  }
207
- function IsFragmentOrNull(vnode) {
208
- return vnode === null || vnode.type === vNode_types_1.FRAGMENT_NODE;
209
- }
210
- function FlattenFragmentsRecursive(children, startIndex, result) {
211
- for (let x = startIndex; x < children.length; x++) {
212
- const vnode = children[x];
213
- switch (vnode.type) {
214
- case vNode_types_1.FRAGMENT_NODE:
215
- FlattenFragmentsRecursive(vnode.children, 0, result);
216
- default:
217
- if (vnode.node !== null)
218
- result.push(vnode.node);
219
- }
208
+ function MapNode(vnode) {
209
+ switch (vnode.type) {
210
+ case vNode_types_1.FRAGMENT_NODE:
211
+ return vnode.children.flatMap(MapNode);
212
+ default:
213
+ return vnode.node;
220
214
  }
221
- return result;
222
215
  }
223
216
  function CleanupChildrenArray(children) {
224
- const index = children.findIndex(IsFragmentOrNull);
225
- if (index < 0)
226
- return children;
227
- const result = [];
228
- FlattenFragmentsRecursive(children, index, result);
229
- return result;
217
+ const nodes = children.flatMap(MapNode);
218
+ (0, array_1.RemoveNulls)(nodes);
219
+ return nodes;
230
220
  }
231
221
  function UpdateChildren(vnode, init = false, skipInit = false) {
232
222
  if (!vnode.children)
@@ -33,7 +33,8 @@ function RemoveNulls(array, startIndex = 0) {
33
33
  notNullIndex++;
34
34
  for (; notNullIndex < array.length && array[notNullIndex] === null; notNullIndex++) { }
35
35
  }
36
- array.splice(nullIndex);
36
+ if (nullIndex < array.length)
37
+ array.splice(nullIndex);
37
38
  }
38
39
  function ArrayDiff(source, target) {
39
40
  if (source === target)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "7.0.103",
3
+ "version": "7.0.105",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",