j-templates 7.0.101 → 7.0.103

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.
@@ -166,7 +166,7 @@ exports.DOMNodeConfig = {
166
166
  break;
167
167
  case 1:
168
168
  lastChild = getHTMLNode(children[0], target.firstChild);
169
- if (lastChild !== null && target.firstChild !== lastChild)
169
+ if (target.firstChild !== lastChild)
170
170
  target.insertBefore(lastChild, target.firstChild);
171
171
  break;
172
172
  default: {
@@ -174,22 +174,20 @@ exports.DOMNodeConfig = {
174
174
  let inNextChildren = false;
175
175
  for (let x = 0; x < children.length; x++) {
176
176
  const nextChild = (lastChild = getHTMLNode(children[x], currentChild));
177
- if (nextChild !== null) {
178
- if (!currentChild)
179
- target.appendChild(nextChild);
180
- else if (nextChild !== currentChild) {
181
- while (currentChild && (!(inNextChildren = inNextChildren || children.indexOf(currentChild, x + 1) >= 0))) {
182
- const toRemove = currentChild;
183
- currentChild = currentChild.nextSibling;
184
- target.removeChild(toRemove);
185
- }
186
- nextChild !== currentChild &&
187
- target.insertBefore(nextChild, currentChild);
177
+ if (!currentChild)
178
+ target.appendChild(nextChild);
179
+ else if (nextChild !== currentChild) {
180
+ while (currentChild && (!(inNextChildren = inNextChildren || children.indexOf(currentChild, x + 1) >= 0))) {
181
+ const toRemove = currentChild;
182
+ currentChild = currentChild.nextSibling;
183
+ target.removeChild(toRemove);
188
184
  }
189
- else
190
- inNextChildren = false;
191
- currentChild = nextChild.nextSibling;
185
+ nextChild !== currentChild &&
186
+ target.insertBefore(nextChild, currentChild);
192
187
  }
188
+ else
189
+ inNextChildren = false;
190
+ currentChild = nextChild.nextSibling;
193
191
  }
194
192
  break;
195
193
  }
package/Node/vNode.js CHANGED
@@ -204,13 +204,29 @@ function ToArray(result) {
204
204
  return result;
205
205
  return [result];
206
206
  }
207
- function GetNode(vnode) {
208
- switch (vnode.type) {
209
- case vNode_types_1.FRAGMENT_NODE:
210
- return vnode.children.flatMap(GetNode);
211
- default:
212
- return vnode.node;
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
+ }
213
220
  }
221
+ return result;
222
+ }
223
+ 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;
214
230
  }
215
231
  function UpdateChildren(vnode, init = false, skipInit = false) {
216
232
  if (!vnode.children)
@@ -234,13 +250,13 @@ function UpdateChildren(vnode, init = false, skipInit = false) {
234
250
  return;
235
251
  if (init) {
236
252
  if (vnode.node !== null)
237
- nodeConfig_1.NodeConfig.reconcileChildren(vnode.node, vnode.children.flatMap(GetNode));
253
+ nodeConfig_1.NodeConfig.reconcileChildren(vnode.node, CleanupChildrenArray(vnode.children));
238
254
  }
239
255
  else if (!async) {
240
256
  let reconcileNode = vnode;
241
257
  while (reconcileNode.node === null)
242
258
  reconcileNode = reconcileNode.parentNode;
243
- nodeConfig_1.NodeConfig.reconcileChildren(reconcileNode.node, reconcileNode.children.flatMap(GetNode));
259
+ nodeConfig_1.NodeConfig.reconcileChildren(reconcileNode.node, CleanupChildrenArray(reconcileNode.children));
244
260
  }
245
261
  else {
246
262
  nodeConfig_1.NodeConfig.scheduleUpdate(function () {
@@ -249,7 +265,7 @@ function UpdateChildren(vnode, init = false, skipInit = false) {
249
265
  let reconcileNode = vnode;
250
266
  while (reconcileNode.node === null)
251
267
  reconcileNode = reconcileNode.parentNode;
252
- nodeConfig_1.NodeConfig.reconcileChildren(reconcileNode.node, reconcileNode.children.flatMap(GetNode));
268
+ nodeConfig_1.NodeConfig.reconcileChildren(reconcileNode.node, CleanupChildrenArray(reconcileNode.children));
253
269
  });
254
270
  }
255
271
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "7.0.101",
3
+ "version": "7.0.103",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",