j-templates 7.0.9 → 7.0.11
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/DOM/domNodeConfig.js +8 -3
- package/Node/vNode.js +26 -23
- package/package.json +1 -1
package/DOM/domNodeConfig.js
CHANGED
|
@@ -142,8 +142,13 @@ exports.DOMNodeConfig = {
|
|
|
142
142
|
target.replaceChildren(...children);
|
|
143
143
|
},
|
|
144
144
|
reconcileChildren(target, children) {
|
|
145
|
-
if (
|
|
146
|
-
|
|
145
|
+
if (!target.firstChild) {
|
|
146
|
+
for (let x = 0; x < children.length; x++)
|
|
147
|
+
target.insertBefore(children[x], null);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (children.length === 0) {
|
|
151
|
+
target.replaceChildren();
|
|
147
152
|
return;
|
|
148
153
|
}
|
|
149
154
|
let actualNode = target.firstChild;
|
|
@@ -168,6 +173,6 @@ exports.DOMNodeConfig = {
|
|
|
168
173
|
while (target.lastChild !== children[x - 1])
|
|
169
174
|
target.removeChild(target.lastChild);
|
|
170
175
|
for (; x < children.length; x++)
|
|
171
|
-
target.
|
|
176
|
+
target.insertBefore(children[x], null);
|
|
172
177
|
}
|
|
173
178
|
};
|
package/Node/vNode.js
CHANGED
|
@@ -141,30 +141,33 @@ function InitNode(vnode) {
|
|
|
141
141
|
}
|
|
142
142
|
function StaticChildren(vnode, children) {
|
|
143
143
|
const childrenScope = Store_1.ObservableScope.Create(WrapStaticChildren(vnode.injector, children));
|
|
144
|
+
vnode.scopes.push(childrenScope);
|
|
144
145
|
const child = Store_1.ObservableScope.Peek(childrenScope);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
146
|
+
switch (typeof child) {
|
|
147
|
+
case 'string': {
|
|
148
|
+
const node = vNode.Create({
|
|
149
|
+
type: "text",
|
|
150
|
+
namespace: null,
|
|
151
|
+
props() {
|
|
152
|
+
return { nodeValue: Store_1.ObservableScope.Value(childrenScope) };
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
vnode.children = [node];
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
default: {
|
|
159
|
+
Store_1.ObservableScope.Touch(childrenScope);
|
|
160
|
+
Store_1.ObservableScope.Watch(childrenScope, CreateScheduledCallback(function () {
|
|
161
|
+
if (vnode.destroyed)
|
|
162
|
+
return;
|
|
163
|
+
vNode.DestroyAll(vnode.children);
|
|
164
|
+
const nodes = Store_1.ObservableScope.Peek(childrenScope);
|
|
165
|
+
vnode.children = Array.isArray(nodes) ? nodes : [nodes];
|
|
166
|
+
UpdateChildren(vnode);
|
|
167
|
+
}));
|
|
168
|
+
vnode.children = (Array.isArray(child) ? child : [child]);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
168
171
|
}
|
|
169
172
|
}
|
|
170
173
|
function WrapStaticChildren(injector, children) {
|