j-templates 7.0.32 → 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.
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare function CreateNodeValueAssignment(target: HTMLElement): (value: string) => void;
|
|
2
|
-
export declare function CreatePropertyAssignment(target: any): (next: {
|
|
2
|
+
export declare function CreatePropertyAssignment(target: any): ((next: {
|
|
3
|
+
nodeValue: string;
|
|
4
|
+
}) => void) | ((next: {
|
|
3
5
|
[prop: string]: any;
|
|
4
|
-
}) => void;
|
|
6
|
+
}) => void);
|
|
5
7
|
export declare function AssignProperties(target: any, next: any): void;
|
|
@@ -52,6 +52,11 @@ function GetAssignmentFunction(path) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
function CreatePropertyAssignment(target) {
|
|
55
|
+
if (target.nodeType === Node.TEXT_NODE) {
|
|
56
|
+
return function (next) {
|
|
57
|
+
AssignNodeValue(target, next.nodeValue);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
55
60
|
const last = [
|
|
56
61
|
["", null, null],
|
|
57
62
|
];
|
package/Node/vNode.js
CHANGED
|
@@ -6,10 +6,6 @@ const injector_1 = require("../Utils/injector");
|
|
|
6
6
|
const list_1 = require("../Utils/list");
|
|
7
7
|
const thread_1 = require("../Utils/thread");
|
|
8
8
|
const nodeConfig_1 = require("./nodeConfig");
|
|
9
|
-
const DEFAULT_VNODE_ARRAY = [undefined];
|
|
10
|
-
function DEFAULT_VNODE_DATA() {
|
|
11
|
-
return DEFAULT_VNODE_ARRAY;
|
|
12
|
-
}
|
|
13
9
|
var vNode;
|
|
14
10
|
(function (vNode) {
|
|
15
11
|
function Create(definition) {
|
|
@@ -17,7 +13,7 @@ var vNode;
|
|
|
17
13
|
definition,
|
|
18
14
|
type: definition.type,
|
|
19
15
|
injector: injector_1.Injector.Current() ?? new injector_1.Injector(),
|
|
20
|
-
node: null,
|
|
16
|
+
node: definition.node ?? null,
|
|
21
17
|
children: null,
|
|
22
18
|
destroyed: false,
|
|
23
19
|
component: null,
|
|
@@ -74,7 +70,7 @@ var vNode;
|
|
|
74
70
|
})(vNode || (exports.vNode = vNode = {}));
|
|
75
71
|
function InitNode(vnode) {
|
|
76
72
|
const { type, namespace, props, attrs, on, data, componentConstructor, children, childrenArray, } = vnode.definition;
|
|
77
|
-
const node = (vnode.node = nodeConfig_1.NodeConfig.createNode(type, namespace));
|
|
73
|
+
const node = (vnode.node = vnode.definition.node ?? nodeConfig_1.NodeConfig.createNode(type, namespace));
|
|
78
74
|
vnode.definition = null;
|
|
79
75
|
if (props) {
|
|
80
76
|
const assignProperties = nodeConfig_1.NodeConfig.createPropertyAssignment(node);
|
|
@@ -138,16 +134,12 @@ function InitNode(vnode) {
|
|
|
138
134
|
vNode.InitAll(vnode.children);
|
|
139
135
|
}
|
|
140
136
|
else if (children) {
|
|
141
|
-
Children(vnode, children, data
|
|
137
|
+
Children(vnode, children, data);
|
|
142
138
|
}
|
|
143
139
|
UpdateChildren(vnode, true, !!childrenArray);
|
|
144
140
|
}
|
|
145
141
|
function Children(vnode, children, data) {
|
|
146
|
-
const
|
|
147
|
-
const childrenScope = Store_1.ObservableScope.Create(WrapChildren(vnode.injector, children, data, nodeList));
|
|
148
|
-
Store_1.ObservableScope.OnDestroyed(childrenScope, function () {
|
|
149
|
-
DestroyNodeList(nodeList);
|
|
150
|
-
});
|
|
142
|
+
const childrenScope = CreateChildrenScope(vnode, children, data);
|
|
151
143
|
vnode.scopes.push(childrenScope);
|
|
152
144
|
Store_1.ObservableScope.Watch(childrenScope, CreateScheduledCallback(function (scope) {
|
|
153
145
|
if (vnode.destroyed)
|
|
@@ -157,28 +149,22 @@ function Children(vnode, children, data) {
|
|
|
157
149
|
}));
|
|
158
150
|
AssignChildren(vnode, childrenScope);
|
|
159
151
|
}
|
|
160
|
-
function
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
default: {
|
|
178
|
-
vnode.children = Array.isArray(children) ? children : [children];
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
152
|
+
function CreateChildrenScope(vnode, children, data) {
|
|
153
|
+
if (data === undefined)
|
|
154
|
+
return Store_1.ObservableScope.Create(WrapStaticChildren(vnode, children));
|
|
155
|
+
const nodeList = list_1.List.Create();
|
|
156
|
+
const scope = Store_1.ObservableScope.Create(WrapChildren(vnode.injector, children, ToArray(data), nodeList));
|
|
157
|
+
Store_1.ObservableScope.OnDestroyed(scope, function () {
|
|
158
|
+
DestroyNodeList(nodeList);
|
|
159
|
+
});
|
|
160
|
+
return scope;
|
|
161
|
+
}
|
|
162
|
+
function WrapStaticChildren(vnode, children) {
|
|
163
|
+
return function () {
|
|
164
|
+
vnode.children && vNode.DestroyAll(vnode.children);
|
|
165
|
+
const childNodes = injector_1.Injector.Scope(vnode.injector, children, undefined);
|
|
166
|
+
return CreateNodeArray(childNodes, vnode.children);
|
|
167
|
+
};
|
|
182
168
|
}
|
|
183
169
|
function WrapChildren(injector, children, data, nodeList) {
|
|
184
170
|
return function () {
|
|
@@ -187,9 +173,6 @@ function WrapChildren(injector, children, data, nodeList) {
|
|
|
187
173
|
case 0:
|
|
188
174
|
DestroyNodeList(nodeList);
|
|
189
175
|
return [];
|
|
190
|
-
case 1:
|
|
191
|
-
DestroyNodeList(nodeList);
|
|
192
|
-
return injector_1.Injector.Scope(injector, children, nextData[0]);
|
|
193
176
|
default: {
|
|
194
177
|
const nodeListMap = list_1.List.ToListMap(nodeList, GetData);
|
|
195
178
|
const nextNodeList = list_1.List.Create();
|
|
@@ -209,14 +192,7 @@ function WrapChildren(injector, children, data, nodeList) {
|
|
|
209
192
|
nodeListMap.delete(data);
|
|
210
193
|
const childrenScope = Store_1.ObservableScope.Create(function () {
|
|
211
194
|
const childNodes = injector_1.Injector.Scope(injector, children, data);
|
|
212
|
-
|
|
213
|
-
type: 'text',
|
|
214
|
-
namespace: null,
|
|
215
|
-
props: {
|
|
216
|
-
nodeValue: childNodes
|
|
217
|
-
}
|
|
218
|
-
})] : Array.isArray(childNodes) ? childNodes : [childNodes];
|
|
219
|
-
return nodes;
|
|
195
|
+
return CreateNodeArray(childNodes);
|
|
220
196
|
});
|
|
221
197
|
list_1.List.Add(nextNodeList, {
|
|
222
198
|
data,
|
|
@@ -234,6 +210,18 @@ function WrapChildren(injector, children, data, nodeList) {
|
|
|
234
210
|
}
|
|
235
211
|
};
|
|
236
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
|
+
}
|
|
237
225
|
function DestroyNodeList(nodeList) {
|
|
238
226
|
for (let node = nodeList.head; node !== null; node = node.next) {
|
|
239
227
|
vNode.DestroyAll(node.data.nodes);
|
|
@@ -244,6 +232,10 @@ function DestroyNodeList(nodeList) {
|
|
|
244
232
|
function GetData(data) {
|
|
245
233
|
return data.data;
|
|
246
234
|
}
|
|
235
|
+
function AssignChildren(vnode, childrenScope) {
|
|
236
|
+
const children = Store_1.ObservableScope.Peek(childrenScope);
|
|
237
|
+
vnode.children = children;
|
|
238
|
+
}
|
|
247
239
|
function UpdateChildren(vnode, init = false, skipInit = false) {
|
|
248
240
|
if (!vnode.children)
|
|
249
241
|
return;
|
|
@@ -252,7 +244,7 @@ function UpdateChildren(vnode, init = false, skipInit = false) {
|
|
|
252
244
|
if (vnode.destroyed || children !== vnode.children)
|
|
253
245
|
return;
|
|
254
246
|
for (let x = 0; !skipInit && x < children.length; x++)
|
|
255
|
-
if (children[x].
|
|
247
|
+
if (children[x].definition) {
|
|
256
248
|
const childNode = children[x];
|
|
257
249
|
(0, thread_1.Schedule)(function () {
|
|
258
250
|
if (vnode.destroyed || children !== vnode.children)
|
package/Node/vNode.types.d.ts
CHANGED