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.
@@ -142,8 +142,13 @@ exports.DOMNodeConfig = {
142
142
  target.replaceChildren(...children);
143
143
  },
144
144
  reconcileChildren(target, children) {
145
- if (children.length === 0 || !target.firstChild) {
146
- target.replaceChildren(...children);
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.appendChild(children[x]);
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
- if (typeof child === "string") {
146
- const node = vNode.Create({
147
- type: "text",
148
- namespace: null,
149
- props() {
150
- return { nodeValue: Store_1.ObservableScope.Value(childrenScope) };
151
- },
152
- });
153
- node.scopes.push(childrenScope);
154
- vnode.children = [node];
155
- }
156
- else {
157
- vnode.scopes.push(childrenScope);
158
- Store_1.ObservableScope.Touch(childrenScope);
159
- Store_1.ObservableScope.Watch(childrenScope, CreateScheduledCallback(function () {
160
- if (vnode.destroyed)
161
- return;
162
- vNode.DestroyAll(vnode.children);
163
- const nodes = Store_1.ObservableScope.Peek(childrenScope);
164
- vnode.children = Array.isArray(nodes) ? nodes : [nodes];
165
- UpdateChildren(vnode);
166
- }));
167
- vnode.children = Array.isArray(child) ? child : [child];
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "7.0.9",
3
+ "version": "7.0.11",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",