webdetta 0.1.234 → 0.1.236
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isIterable, isObject,
|
|
1
|
+
import { isIterable, isObject, callFn } from '../common/utils.js';
|
|
2
2
|
import { once } from '../execution/index.js';
|
|
3
3
|
import { r } from '../reactivity/index.js';
|
|
4
4
|
import { Element, Operator, processItem } from './base.js';
|
|
@@ -15,12 +15,13 @@ const listItemsToEntries = (items, keyFn) => new Map(
|
|
|
15
15
|
: null
|
|
16
16
|
);
|
|
17
17
|
|
|
18
|
+
const lastNodes = new WeakMap();
|
|
18
19
|
const createContainer = (content) => {
|
|
19
20
|
let startNode;
|
|
20
21
|
|
|
21
22
|
const nodes = [], operators = [];
|
|
22
23
|
const contentEffect = r.effect(() => {
|
|
23
|
-
const items =
|
|
24
|
+
const items = callFn(content);
|
|
24
25
|
processItem(items, o => operators.push(o), c => nodes.push(c), true);
|
|
25
26
|
if (startNode) appendAfter(startNode);
|
|
26
27
|
return () => {
|
|
@@ -41,9 +42,10 @@ const createContainer = (content) => {
|
|
|
41
42
|
let lastNode = startNode = newStartNode;
|
|
42
43
|
if (parentChanged) operatorsEffect.run();
|
|
43
44
|
for (const node of nodes) {
|
|
44
|
-
if (
|
|
45
|
-
lastNode = node;
|
|
45
|
+
if (lastNode.nextSibling !== node) Element.appendAfter(lastNode, node);
|
|
46
|
+
lastNode = lastNodes.get(node) ?? node;
|
|
46
47
|
}
|
|
48
|
+
lastNodes.set(newStartNode, lastNode);
|
|
47
49
|
return lastNode;
|
|
48
50
|
};
|
|
49
51
|
|
|
@@ -69,7 +71,7 @@ export const createList = (itemsFn, renderItem, keyFn = listItemKey) => {
|
|
|
69
71
|
});
|
|
70
72
|
|
|
71
73
|
const effect = r.effect(() => {
|
|
72
|
-
const items =
|
|
74
|
+
const items = callFn(itemsFn);
|
|
73
75
|
const entries = listItemsToEntries(items, keyFn);
|
|
74
76
|
|
|
75
77
|
let last = root, i = 0;
|
|
@@ -104,7 +106,7 @@ export const createSlot = (content) => {
|
|
|
104
106
|
export const createIf = () => {
|
|
105
107
|
const conditions = [];
|
|
106
108
|
const node = createSlot(() =>
|
|
107
|
-
conditions.find(d =>
|
|
109
|
+
conditions.find(d => callFn(d.cond))?.value
|
|
108
110
|
);
|
|
109
111
|
|
|
110
112
|
node.elif = (cond, ...args) => {
|