j-templates 7.0.33 → 7.0.34

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 (2) hide show
  1. package/Node/vNode.js +16 -26
  2. package/package.json +1 -1
package/Node/vNode.js CHANGED
@@ -162,7 +162,8 @@ function CreateChildrenScope(vnode, children, data) {
162
162
  function WrapStaticChildren(vnode, children) {
163
163
  return function () {
164
164
  vnode.children && vNode.DestroyAll(vnode.children);
165
- return injector_1.Injector.Scope(vnode.injector, children, undefined);
165
+ const childNodes = injector_1.Injector.Scope(vnode.injector, children, undefined);
166
+ return CreateNodeArray(childNodes, vnode.children);
166
167
  };
167
168
  }
168
169
  function WrapChildren(injector, children, data, nodeList) {
@@ -191,14 +192,7 @@ function WrapChildren(injector, children, data, nodeList) {
191
192
  nodeListMap.delete(data);
192
193
  const childrenScope = Store_1.ObservableScope.Create(function () {
193
194
  const childNodes = injector_1.Injector.Scope(injector, children, data);
194
- const nodes = typeof childNodes === 'string' ? [vNode.Create({
195
- type: 'text',
196
- namespace: null,
197
- props: {
198
- nodeValue: childNodes
199
- }
200
- })] : Array.isArray(childNodes) ? childNodes : [childNodes];
201
- return nodes;
195
+ return CreateNodeArray(childNodes);
202
196
  });
203
197
  list_1.List.Add(nextNodeList, {
204
198
  data,
@@ -216,6 +210,18 @@ function WrapChildren(injector, children, data, nodeList) {
216
210
  }
217
211
  };
218
212
  }
213
+ function CreateNodeArray(children, previousChildren) {
214
+ if (Array.isArray(children))
215
+ return children;
216
+ return typeof children === 'string' ? [vNode.Create({
217
+ type: 'text',
218
+ namespace: null,
219
+ node: previousChildren?.[0]?.type === 'text' && previousChildren[0].node || undefined,
220
+ props: {
221
+ nodeValue: children
222
+ }
223
+ })] : [children];
224
+ }
219
225
  function DestroyNodeList(nodeList) {
220
226
  for (let node = nodeList.head; node !== null; node = node.next) {
221
227
  vNode.DestroyAll(node.data.nodes);
@@ -228,23 +234,7 @@ function GetData(data) {
228
234
  }
229
235
  function AssignChildren(vnode, childrenScope) {
230
236
  const children = Store_1.ObservableScope.Peek(childrenScope);
231
- switch (typeof children) {
232
- case 'string': {
233
- vnode.children = [vNode.Create({
234
- type: 'text',
235
- namespace: null,
236
- node: vnode.children?.[0]?.type === 'text' && vnode.children[0].node || undefined,
237
- props: {
238
- nodeValue: children
239
- }
240
- })];
241
- break;
242
- }
243
- default: {
244
- vnode.children = Array.isArray(children) ? children : [children];
245
- break;
246
- }
247
- }
237
+ vnode.children = children;
248
238
  }
249
239
  function UpdateChildren(vnode, init = false, skipInit = false) {
250
240
  if (!vnode.children)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "7.0.33",
3
+ "version": "7.0.34",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",