j-templates 7.0.93 → 7.0.95
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 +40 -9
- package/DOM/elements.d.ts +98 -768
- package/DOM/elements.js +8 -2
- package/Node/nodeConfig.d.ts +1 -0
- package/Node/vNode.d.ts +4 -15
- package/Node/vNode.js +47 -31
- package/Node/vNode.types.d.ts +15 -3
- package/Node/vNode.types.js +5 -1
- package/Store/Store/storeSync.js +1 -1
- package/Store/Tree/observableNode.d.ts +2 -1
- package/Store/Tree/observableNode.js +42 -8
- package/Store/Tree/observableScope.d.ts +2 -4
- package/Store/Tree/observableScope.js +7 -8
- package/Utils/decorators.js +5 -2
- package/Utils/emitter.js +2 -4
- package/Utils/json.d.ts +2 -2
- package/Utils/json.js +1 -2
- package/Utils/scheduling.d.ts +4 -0
- package/Utils/scheduling.js +26 -0
- package/Utils/thread.js +3 -5
- package/package.json +1 -1
- package/DOM/window.d.ts +0 -1
- package/DOM/window.js +0 -12
- package/Utils/distinctArray.d.ts +0 -12
- package/Utils/distinctArray.js +0 -49
- /package/{Utils → _not_used}/array.d.ts +0 -0
- /package/{Utils → _not_used}/array.js +0 -0
- /package/{Utils → _not_used}/avlTree.d.ts +0 -0
- /package/{Utils → _not_used}/avlTree.js +0 -0
package/DOM/domNodeConfig.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DOMNodeConfig = void 0;
|
|
4
|
-
const window_1 = require("./window");
|
|
5
4
|
const list_1 = require("../Utils/list");
|
|
5
|
+
const scheduling_1 = require("../Utils/scheduling");
|
|
6
6
|
const createPropertyAssignment_1 = require("./createPropertyAssignment");
|
|
7
7
|
const createEventAssignment_1 = require("./createEventAssignment");
|
|
8
8
|
const createAssignment_1 = require("./createAssignment");
|
|
@@ -20,7 +20,7 @@ function processUpdates() {
|
|
|
20
20
|
updateScheduled = false;
|
|
21
21
|
else {
|
|
22
22
|
frameStart = Date.now();
|
|
23
|
-
|
|
23
|
+
(0, scheduling_1._requestAnimationFrame)(processUpdates);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
let highPriority = false;
|
|
@@ -33,10 +33,10 @@ function scheduleUpdate(callback) {
|
|
|
33
33
|
const now = Date.now();
|
|
34
34
|
updateScheduled = true;
|
|
35
35
|
if (now - frameStart < frameTime)
|
|
36
|
-
|
|
36
|
+
(0, scheduling_1._queueMicrotask)(processUpdates);
|
|
37
37
|
else {
|
|
38
38
|
frameStart = now;
|
|
39
|
-
|
|
39
|
+
(0, scheduling_1._requestAnimationFrame)(processUpdates);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -60,14 +60,12 @@ function getHTMLNode(from, current) {
|
|
|
60
60
|
}
|
|
61
61
|
exports.DOMNodeConfig = {
|
|
62
62
|
createNode(type, namespace) {
|
|
63
|
-
if (type === "text")
|
|
64
|
-
return window_1.wndw.document.createTextNode("");
|
|
65
63
|
return namespace
|
|
66
|
-
?
|
|
67
|
-
:
|
|
64
|
+
? document.createElementNS(namespace, type)
|
|
65
|
+
: document.createElement(type);
|
|
68
66
|
},
|
|
69
67
|
createTextNode(value = "") {
|
|
70
|
-
return
|
|
68
|
+
return document.createTextNode(value);
|
|
71
69
|
},
|
|
72
70
|
isTextNode(target) {
|
|
73
71
|
return target?.nodeType === Node.TEXT_NODE;
|
|
@@ -196,5 +194,38 @@ exports.DOMNodeConfig = {
|
|
|
196
194
|
}
|
|
197
195
|
while (target.lastChild !== lastChild)
|
|
198
196
|
target.removeChild(target.lastChild);
|
|
197
|
+
},
|
|
198
|
+
// start is exclusive (null for beginning), end is also exclusive (null for end)
|
|
199
|
+
reconcileRange(target, start, end, children) {
|
|
200
|
+
if ((start && start.parentNode !== target) || (end && end.parentNode !== target))
|
|
201
|
+
throw new Error("Can't reconcile range against elements that are not children of the provided parent");
|
|
202
|
+
if (start && end && start === end)
|
|
203
|
+
throw new Error("Can't reconcile zero element range. Provided elements are equal.");
|
|
204
|
+
let currentChild = (start?.nextSibling ?? target.firstChild);
|
|
205
|
+
let inNextChildren = false;
|
|
206
|
+
for (let x = 0; x < children.length; x++) {
|
|
207
|
+
const nextAddedChild = getHTMLNode(children[x], currentChild);
|
|
208
|
+
if (!currentChild)
|
|
209
|
+
target.appendChild(nextAddedChild);
|
|
210
|
+
else if (currentChild === end)
|
|
211
|
+
target.insertBefore(nextAddedChild, currentChild);
|
|
212
|
+
else if (nextAddedChild !== currentChild) {
|
|
213
|
+
while (currentChild && currentChild !== end && (!(inNextChildren = inNextChildren || children.indexOf(currentChild, x + 1) >= 0))) {
|
|
214
|
+
const toRemove = currentChild;
|
|
215
|
+
currentChild = currentChild.nextSibling;
|
|
216
|
+
target.removeChild(toRemove);
|
|
217
|
+
}
|
|
218
|
+
nextAddedChild !== currentChild &&
|
|
219
|
+
target.insertBefore(nextAddedChild, currentChild);
|
|
220
|
+
}
|
|
221
|
+
else
|
|
222
|
+
inNextChildren = false;
|
|
223
|
+
currentChild = nextAddedChild.nextSibling;
|
|
224
|
+
}
|
|
225
|
+
while (currentChild !== end) {
|
|
226
|
+
const toRemove = currentChild;
|
|
227
|
+
currentChild = currentChild.nextSibling;
|
|
228
|
+
target.removeChild(toRemove);
|
|
229
|
+
}
|
|
199
230
|
}
|
|
200
231
|
};
|