j-templates 7.0.42 → 7.0.43

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 +11 -20
  2. package/package.json +1 -1
package/Node/vNode.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.vNode = void 0;
4
4
  const Store_1 = require("../Store");
5
- const functions_1 = require("../Utils/functions");
6
5
  const injector_1 = require("../Utils/injector");
7
6
  const list_1 = require("../Utils/list");
8
7
  const thread_1 = require("../Utils/thread");
@@ -153,18 +152,20 @@ function Children(vnode, children, data) {
153
152
  function CreateChildrenScope(vnode, children, data) {
154
153
  if (data === undefined)
155
154
  return Store_1.ObservableScope.Create(WrapStaticChildren(vnode, children));
156
- const dataIsAsync = (0, functions_1.IsAsync)(data);
157
- if (dataIsAsync) {
158
- const dataScope = Store_1.ObservableScope.Create(data);
159
- vnode.scopes.push(dataScope);
160
- data = function () {
161
- return Store_1.ObservableScope.Value(dataScope);
162
- };
163
- }
155
+ const dataScope = Store_1.ObservableScope.Create(data);
156
+ data = function () {
157
+ const result = Store_1.ObservableScope.Value(dataScope);
158
+ if (!result)
159
+ return [];
160
+ if (Array.isArray(result))
161
+ return result;
162
+ return [result];
163
+ };
164
164
  const nodeList = list_1.List.Create();
165
- const scope = Store_1.ObservableScope.Create(WrapChildren(vnode.injector, children, ToArray(data), nodeList));
165
+ const scope = Store_1.ObservableScope.Create(WrapChildren(vnode.injector, children, data, nodeList));
166
166
  Store_1.ObservableScope.OnDestroyed(scope, function () {
167
167
  DestroyNodeList(nodeList);
168
+ Store_1.ObservableScope.Destroy(dataScope);
168
169
  });
169
170
  return scope;
170
171
  }
@@ -277,16 +278,6 @@ function UpdateChildren(vnode, init = false, skipInit = false) {
277
278
  });
278
279
  });
279
280
  }
280
- function ToArray(callback) {
281
- return function (...args) {
282
- const result = callback(...args);
283
- if (Array.isArray(result))
284
- return result;
285
- if (!result)
286
- return [];
287
- return [result];
288
- };
289
- }
290
281
  function ScheduledAssignment(assign) {
291
282
  let scheduled = false;
292
283
  return function (scope) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "7.0.42",
3
+ "version": "7.0.43",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",