j-templates 7.0.3 → 7.0.5
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 +25 -2
- package/package.json +1 -1
package/Node/vNode.js
CHANGED
|
@@ -113,6 +113,8 @@ function InitNode(vnode) {
|
|
|
113
113
|
});
|
|
114
114
|
vnode.scopes.push(componentScope);
|
|
115
115
|
Store_1.ObservableScope.Watch(componentScope, CreateScheduledCallback(function () {
|
|
116
|
+
if (vnode.destroyed)
|
|
117
|
+
return;
|
|
116
118
|
const nodes = Store_1.ObservableScope.Peek(componentScope);
|
|
117
119
|
vNode.DestroyAll(vnode.children);
|
|
118
120
|
vnode.children = nodes;
|
|
@@ -151,6 +153,8 @@ function StaticChildren(vnode, children) {
|
|
|
151
153
|
vnode.scopes.push(childrenScope);
|
|
152
154
|
Store_1.ObservableScope.Touch(childrenScope);
|
|
153
155
|
Store_1.ObservableScope.Watch(childrenScope, CreateScheduledCallback(function () {
|
|
156
|
+
if (vnode.destroyed)
|
|
157
|
+
return;
|
|
154
158
|
vNode.DestroyAll(vnode.children);
|
|
155
159
|
const nodes = Store_1.ObservableScope.Peek(childrenScope);
|
|
156
160
|
vnode.children = Array.isArray(nodes) ? nodes : [nodes];
|
|
@@ -180,6 +184,8 @@ function DynamicChildren(vnode, children, data) {
|
|
|
180
184
|
DestroyNodeList(nodeList);
|
|
181
185
|
});
|
|
182
186
|
Store_1.ObservableScope.Watch(childrenScope, CreateScheduledCallback(function () {
|
|
187
|
+
if (vnode.destroyed)
|
|
188
|
+
return;
|
|
183
189
|
vnode.children = Store_1.ObservableScope.Peek(childrenScope);
|
|
184
190
|
UpdateChildren(vnode);
|
|
185
191
|
}));
|
|
@@ -213,7 +219,18 @@ function WrapDynamicChildren(dataScope, nodeList, injector, children) {
|
|
|
213
219
|
else {
|
|
214
220
|
const childrenScope = Store_1.ObservableScope.Create(function () {
|
|
215
221
|
const childNodes = injector_1.Injector.Scope(injector, children, data);
|
|
216
|
-
|
|
222
|
+
const nodes = Array.isArray(childNodes) ? childNodes : [childNodes];
|
|
223
|
+
for (let x = 0; x < nodes.length; x++) {
|
|
224
|
+
if (typeof nodes[x] === 'string')
|
|
225
|
+
nodes[x] = vNode.Create({
|
|
226
|
+
type: 'text',
|
|
227
|
+
namespace: null,
|
|
228
|
+
props: {
|
|
229
|
+
nodeValue: nodes[x]
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return nodes;
|
|
217
234
|
});
|
|
218
235
|
list_1.List.Add(nextNodeList, {
|
|
219
236
|
data,
|
|
@@ -276,6 +293,8 @@ function ScheduledAssignment(assign) {
|
|
|
276
293
|
return;
|
|
277
294
|
scheduled = true;
|
|
278
295
|
nodeConfig_1.NodeConfig.scheduleUpdate(function () {
|
|
296
|
+
if (scope.destroyed)
|
|
297
|
+
return;
|
|
279
298
|
scheduled = false;
|
|
280
299
|
const value = Store_1.ObservableScope.Peek(scope);
|
|
281
300
|
assign(value);
|
|
@@ -287,6 +306,10 @@ function CreateScheduledCallback(callback) {
|
|
|
287
306
|
return function () {
|
|
288
307
|
if (scheduled)
|
|
289
308
|
return;
|
|
290
|
-
|
|
309
|
+
scheduled = true;
|
|
310
|
+
nodeConfig_1.NodeConfig.scheduleUpdate(function () {
|
|
311
|
+
scheduled = false;
|
|
312
|
+
callback();
|
|
313
|
+
});
|
|
291
314
|
};
|
|
292
315
|
}
|