@jsswift/core 1.0.41
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/dist/cms.js +5280 -0
- package/dist/cms.min.js +1 -0
- package/dist/min-cms.js +1 -0
- package/package.json +27 -0
- package/src/00-bootstrap.js +393 -0
- package/src/09-overlay-shared.js +162 -0
- package/src/10-overlay.js +213 -0
- package/src/15-dom-props.js +211 -0
- package/src/16-renderer-shared.js +308 -0
- package/src/17-renderer-children.js +134 -0
- package/src/18-renderer-args.js +73 -0
- package/src/20-renderer.js +575 -0
- package/src/30-rod-core.js +270 -0
- package/src/31-rod-model.js +157 -0
- package/src/32-lifecycle-helpers.js +84 -0
- package/src/32-lifecycle.js +131 -0
- package/src/33-debug-perf.js +176 -0
- package/src/34-rod-devtools.js +43 -0
- package/src/39-store-shared.js +60 -0
- package/src/40-store-core.js +203 -0
- package/src/41-store-extensions.js +194 -0
- package/src/42-plugins.js +163 -0
- package/src/42a-auth-shared.js +148 -0
- package/src/43-auth.js +171 -0
- package/src/43a-http-shared.js +234 -0
- package/src/44-http.js +157 -0
- package/src/45-route-hooks.js +55 -0
- package/src/49-router-shared.js +99 -0
- package/src/49a-ui-meta-shared.js +116 -0
- package/src/50-ui-meta.js +189 -0
- package/src/51-can.js +20 -0
- package/src/52-router.js +399 -0
- package/src/53-footer.js +142 -0
- package/src/README.md +58 -0
- package/src/modules.json +31 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/* ===============================
|
|
2
|
+
Renderer shared helpers
|
|
3
|
+
=============================== */
|
|
4
|
+
|
|
5
|
+
function normalizeClass(v) {
|
|
6
|
+
const tokens = [];
|
|
7
|
+
const add = (value) => {
|
|
8
|
+
if (value == null || value === false) return;
|
|
9
|
+
if (typeof value === "function") {
|
|
10
|
+
add(value());
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (value && value.type === "rod") {
|
|
14
|
+
add(value.value);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
value.forEach(add);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (typeof value === "object") {
|
|
22
|
+
Object.entries(value).forEach(([className, enabled]) => {
|
|
23
|
+
let resolved = enabled;
|
|
24
|
+
if (typeof resolved === "function") resolved = resolved();
|
|
25
|
+
else if (resolved && resolved.type === "rod") resolved = resolved.value;
|
|
26
|
+
add(resolved ? className : null);
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (value === true) return;
|
|
31
|
+
String(value).split(/\s+/).forEach((token) => {
|
|
32
|
+
if (token) tokens.push(token);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
add(v);
|
|
37
|
+
return tokens.length ? Array.from(new Set(tokens)).join(" ") : "";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function hasDynamicClassValue(value) {
|
|
41
|
+
if (value == null || value === false) return false;
|
|
42
|
+
if (typeof value === "function") return true;
|
|
43
|
+
if (value && value.type === "rod") return true;
|
|
44
|
+
if (Array.isArray(value)) return value.some(hasDynamicClassValue);
|
|
45
|
+
if (typeof value === "object") return Object.values(value).some(hasDynamicClassValue);
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function hasDynamicStyleValue(value, isRod) {
|
|
50
|
+
if (value == null || value === false) return false;
|
|
51
|
+
if (typeof value === "function") return true;
|
|
52
|
+
if (isRod(value)) return true;
|
|
53
|
+
if (typeof value !== "object" || Array.isArray(value) || value.nodeType) return false;
|
|
54
|
+
return Object.values(value).some((entry) => hasDynamicStyleValue(entry, isRod));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function resolveStyleObject(value, isRod) {
|
|
58
|
+
let next = value;
|
|
59
|
+
if (typeof next === "function") next = next();
|
|
60
|
+
else if (isRod(next)) next = next.value;
|
|
61
|
+
|
|
62
|
+
if (!next || typeof next !== "object" || Array.isArray(next) || next.nodeType) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const out = {};
|
|
67
|
+
Object.entries(next).forEach(([styleName, styleValue]) => {
|
|
68
|
+
let resolved = styleValue;
|
|
69
|
+
if (typeof resolved === "function") resolved = resolved();
|
|
70
|
+
else if (isRod(resolved)) resolved = resolved.value;
|
|
71
|
+
out[styleName] = resolved;
|
|
72
|
+
});
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function createStyleObjectApplier(setStyleEntry) {
|
|
77
|
+
let previousKeys = new Set();
|
|
78
|
+
|
|
79
|
+
function clearMissing(nextKeys) {
|
|
80
|
+
previousKeys.forEach((styleName) => {
|
|
81
|
+
if (!nextKeys.has(styleName)) setStyleEntry(styleName, null);
|
|
82
|
+
});
|
|
83
|
+
previousKeys = nextKeys;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function apply(value, isRod) {
|
|
87
|
+
const nextStyle = resolveStyleObject(value, isRod);
|
|
88
|
+
if (!nextStyle) {
|
|
89
|
+
clearMissing(new Set());
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const nextKeys = new Set(Object.keys(nextStyle));
|
|
94
|
+
clearMissing(nextKeys);
|
|
95
|
+
Object.entries(nextStyle).forEach(([styleName, styleValue]) => {
|
|
96
|
+
setStyleEntry(styleName, styleValue);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return { apply };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function isEventProp(key) {
|
|
104
|
+
return typeof key === "string" && (key.startsWith("on:") || (key.startsWith("on") && key.length > 2));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const ROD_INTERPOLATION_BUFFER_LIMIT = 128;
|
|
108
|
+
const rodInterpolationBuffer = [];
|
|
109
|
+
|
|
110
|
+
function trackRodInterpolation(rod, value) {
|
|
111
|
+
rodInterpolationBuffer.push({ rod, value: String(value ?? "") });
|
|
112
|
+
if (rodInterpolationBuffer.length > ROD_INTERPOLATION_BUFFER_LIMIT) {
|
|
113
|
+
rodInterpolationBuffer.splice(0, rodInterpolationBuffer.length - ROD_INTERPOLATION_BUFFER_LIMIT);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function createRodInterpolationCursor() {
|
|
118
|
+
if (!rodInterpolationBuffer.length) return null;
|
|
119
|
+
const items = rodInterpolationBuffer.slice();
|
|
120
|
+
rodInterpolationBuffer.length = 0;
|
|
121
|
+
return { items, index: 0 };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function takeInterpolatedSegments(text, cursor) {
|
|
125
|
+
if (!cursor || !text || cursor.index >= cursor.items.length) return null;
|
|
126
|
+
|
|
127
|
+
const segments = [];
|
|
128
|
+
const source = String(text);
|
|
129
|
+
let offset = 0;
|
|
130
|
+
let nextIndex = cursor.index;
|
|
131
|
+
let matched = false;
|
|
132
|
+
|
|
133
|
+
while (nextIndex < cursor.items.length) {
|
|
134
|
+
const entry = cursor.items[nextIndex];
|
|
135
|
+
const needle = entry.value;
|
|
136
|
+
if (!needle) break;
|
|
137
|
+
|
|
138
|
+
const pos = source.indexOf(needle, offset);
|
|
139
|
+
if (pos === -1) break;
|
|
140
|
+
|
|
141
|
+
if (pos > offset) segments.push(source.slice(offset, pos));
|
|
142
|
+
segments.push(entry.rod);
|
|
143
|
+
offset = pos + needle.length;
|
|
144
|
+
nextIndex++;
|
|
145
|
+
matched = true;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!matched) return null;
|
|
149
|
+
if (offset < source.length) segments.push(source.slice(offset));
|
|
150
|
+
cursor.index = nextIndex;
|
|
151
|
+
return segments;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function renderInterpolatedSegments(segments) {
|
|
155
|
+
let out = "";
|
|
156
|
+
for (const part of segments) {
|
|
157
|
+
if (typeof part === "string") out += part;
|
|
158
|
+
else out += part?.value ?? "";
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function getEventName(key) {
|
|
164
|
+
if (key.startsWith("on:")) return key.slice(3);
|
|
165
|
+
const raw = key.slice(2);
|
|
166
|
+
if (!raw) return "";
|
|
167
|
+
if (raw === "DoubleClick") return "dblclick";
|
|
168
|
+
return raw.toLowerCase();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function normalizeEventOptions(options) {
|
|
172
|
+
if (options == null || options === false) return false;
|
|
173
|
+
if (options === true) return { capture: true };
|
|
174
|
+
if (typeof options === "boolean") return options;
|
|
175
|
+
if (typeof options === "object") {
|
|
176
|
+
return {
|
|
177
|
+
capture: !!options.capture,
|
|
178
|
+
passive: !!options.passive,
|
|
179
|
+
once: !!options.once
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function eventOptionsEqual(a, b) {
|
|
186
|
+
const left = normalizeEventOptions(a);
|
|
187
|
+
const right = normalizeEventOptions(b);
|
|
188
|
+
if (typeof left === "boolean" || typeof right === "boolean") return left === right;
|
|
189
|
+
return !!left && !!right
|
|
190
|
+
&& left.capture === right.capture
|
|
191
|
+
&& left.passive === right.passive
|
|
192
|
+
&& left.once === right.once;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function hasDynamicEventValue(value, isRod) {
|
|
196
|
+
if (Array.isArray(value)) return value.some((entry) => hasDynamicEventValue(entry, isRod));
|
|
197
|
+
if (isRod(value)) return true;
|
|
198
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || value.nodeType) return false;
|
|
199
|
+
if (Array.isArray(value.handlers)) return value.handlers.some((entry) => hasDynamicEventValue(entry, isRod)) || isRod(value.options) || typeof value.options === "function";
|
|
200
|
+
if (Array.isArray(value.listeners)) return value.listeners.some((entry) => hasDynamicEventValue(entry, isRod)) || isRod(value.options) || typeof value.options === "function";
|
|
201
|
+
return isRod(value.handler)
|
|
202
|
+
|| isRod(value.listener)
|
|
203
|
+
|| isRod(value.fn)
|
|
204
|
+
|| isRod(value.options)
|
|
205
|
+
|| typeof value.options === "function";
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function normalizeEventEntry(value, isRod, inheritedOptions) {
|
|
209
|
+
if (value == null || value === false) {
|
|
210
|
+
return [];
|
|
211
|
+
}
|
|
212
|
+
if (typeof value === "function") {
|
|
213
|
+
return [{ handler: value, options: normalizeEventOptions(inheritedOptions ?? false) }];
|
|
214
|
+
}
|
|
215
|
+
if (isRod(value)) {
|
|
216
|
+
return normalizeEventEntry(value.value, isRod, inheritedOptions);
|
|
217
|
+
}
|
|
218
|
+
if (Array.isArray(value)) {
|
|
219
|
+
return value.flatMap((entry) => normalizeEventEntry(entry, isRod, inheritedOptions));
|
|
220
|
+
}
|
|
221
|
+
if (typeof value === "object" && !Array.isArray(value) && !value.nodeType) {
|
|
222
|
+
if (Array.isArray(value.handlers) || Array.isArray(value.listeners)) {
|
|
223
|
+
const handlers = value.handlers || value.listeners || [];
|
|
224
|
+
const sharedOptions = value.options ?? inheritedOptions ?? false;
|
|
225
|
+
return handlers.flatMap((entry) => normalizeEventEntry(entry, isRod, sharedOptions));
|
|
226
|
+
}
|
|
227
|
+
let handler = value.handler ?? value.listener ?? value.fn ?? null;
|
|
228
|
+
let options = value.options ?? inheritedOptions ?? false;
|
|
229
|
+
if (isRod(handler)) handler = handler.value;
|
|
230
|
+
if (isRod(options)) options = options.value;
|
|
231
|
+
if (typeof options === "function") options = options();
|
|
232
|
+
return typeof handler === "function"
|
|
233
|
+
? [{ handler, options: normalizeEventOptions(options) }]
|
|
234
|
+
: [];
|
|
235
|
+
}
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function normalizeEventValue(value, isRod) {
|
|
240
|
+
return normalizeEventEntry(value, isRod);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function bindEventProp(el, key, value, isRod) {
|
|
244
|
+
const eventName = getEventName(key);
|
|
245
|
+
if (!eventName) return;
|
|
246
|
+
|
|
247
|
+
const state = {
|
|
248
|
+
listeners: []
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const detach = () => {
|
|
252
|
+
state.listeners.forEach((entry) => {
|
|
253
|
+
el.removeEventListener(eventName, entry.dispatch, entry.options);
|
|
254
|
+
});
|
|
255
|
+
state.listeners = [];
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const apply = (nextValue) => {
|
|
259
|
+
const nextListeners = normalizeEventValue(nextValue, isRod);
|
|
260
|
+
const isSameShape = state.listeners.length === nextListeners.length && state.listeners.every((entry, index) => {
|
|
261
|
+
const next = nextListeners[index];
|
|
262
|
+
return entry.handler === next.handler && eventOptionsEqual(entry.options, next.options);
|
|
263
|
+
});
|
|
264
|
+
if (isSameShape) return;
|
|
265
|
+
|
|
266
|
+
detach();
|
|
267
|
+
|
|
268
|
+
nextListeners.forEach((listener) => {
|
|
269
|
+
const entry = {
|
|
270
|
+
handler: listener.handler,
|
|
271
|
+
options: listener.options,
|
|
272
|
+
dispatch: null
|
|
273
|
+
};
|
|
274
|
+
entry.dispatch = (event) => {
|
|
275
|
+
if (typeof entry.handler === "function") {
|
|
276
|
+
const result = entry.handler.call(el, event);
|
|
277
|
+
if (entry.options && typeof entry.options === "object" && entry.options.once) {
|
|
278
|
+
el.removeEventListener(eventName, entry.dispatch, entry.options);
|
|
279
|
+
state.listeners = state.listeners.filter((item) => item !== entry);
|
|
280
|
+
}
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
el.addEventListener(eventName, entry.dispatch, entry.options);
|
|
285
|
+
state.listeners.push(entry);
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
JSswift._registerCleanup(el, detach);
|
|
290
|
+
|
|
291
|
+
if (isRod(value)) {
|
|
292
|
+
const stop = JSswift.reactive.effect(() => {
|
|
293
|
+
apply(value.value);
|
|
294
|
+
});
|
|
295
|
+
JSswift._registerCleanup(el, stop);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (hasDynamicEventValue(value, isRod)) {
|
|
300
|
+
const stop = JSswift.reactive.effect(() => {
|
|
301
|
+
apply(value);
|
|
302
|
+
});
|
|
303
|
+
JSswift._registerCleanup(el, stop);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
apply(value);
|
|
308
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/* ===============================
|
|
2
|
+
Renderer child helpers
|
|
3
|
+
=============================== */
|
|
4
|
+
|
|
5
|
+
function createRendererChildHelpers(el, options = {}) {
|
|
6
|
+
const {
|
|
7
|
+
isRod = () => false,
|
|
8
|
+
interpolationCursor = null
|
|
9
|
+
} = options;
|
|
10
|
+
|
|
11
|
+
function createRodTextNode(rod) {
|
|
12
|
+
const t = document.createTextNode("");
|
|
13
|
+
const unbind = JSswift.rodBind(t, rod);
|
|
14
|
+
JSswift._registerCleanup(t, unbind);
|
|
15
|
+
return t;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function appendRodText(rod) {
|
|
19
|
+
el.appendChild(createRodTextNode(rod));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function appendInterpolatedText(segments) {
|
|
23
|
+
const t = document.createTextNode("");
|
|
24
|
+
el.appendChild(t);
|
|
25
|
+
const stop = JSswift.reactive.effect(() => {
|
|
26
|
+
t.textContent = renderInterpolatedSegments(segments);
|
|
27
|
+
});
|
|
28
|
+
JSswift._registerCleanup(t, stop);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function normalizeDynamicChildNodes(value) {
|
|
32
|
+
const out = [];
|
|
33
|
+
const add = (item) => {
|
|
34
|
+
if (item == null || item === false) return;
|
|
35
|
+
if (Array.isArray(item)) {
|
|
36
|
+
item.forEach(add);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (typeof item === "string") {
|
|
40
|
+
out.push(document.createTextNode(item));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (typeof item === "number") {
|
|
44
|
+
out.push(document.createTextNode(String(item)));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (typeof item === "boolean") return;
|
|
48
|
+
if (isRod(item)) {
|
|
49
|
+
out.push(createRodTextNode(item));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (item?.nodeType) {
|
|
53
|
+
out.push(item);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
out.push(document.createTextNode(String(item)));
|
|
57
|
+
};
|
|
58
|
+
add(value);
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function appendDynamicChild(renderFn) {
|
|
63
|
+
const anchor = document.createComment("dyn");
|
|
64
|
+
el.appendChild(anchor);
|
|
65
|
+
let currentNodes = [];
|
|
66
|
+
|
|
67
|
+
const stop = JSswift.reactive.effect(() => {
|
|
68
|
+
currentNodes.forEach((node) => {
|
|
69
|
+
cleanupNodeTree(node);
|
|
70
|
+
if (node.parentNode) node.parentNode.removeChild(node);
|
|
71
|
+
});
|
|
72
|
+
currentNodes = [];
|
|
73
|
+
|
|
74
|
+
const parent = anchor.parentNode;
|
|
75
|
+
if (!parent) return;
|
|
76
|
+
|
|
77
|
+
const nextNodes = normalizeDynamicChildNodes(renderFn());
|
|
78
|
+
if (!nextNodes.length) return;
|
|
79
|
+
|
|
80
|
+
const frag = document.createDocumentFragment();
|
|
81
|
+
nextNodes.forEach((node) => frag.appendChild(node));
|
|
82
|
+
parent.insertBefore(frag, anchor.nextSibling);
|
|
83
|
+
currentNodes = nextNodes;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
JSswift._registerCleanup(anchor, () => {
|
|
87
|
+
stop();
|
|
88
|
+
currentNodes.forEach((node) => cleanupNodeTree(node));
|
|
89
|
+
currentNodes = [];
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function appendChildValue(value) {
|
|
94
|
+
if (value == null) return;
|
|
95
|
+
|
|
96
|
+
if (Array.isArray(value)) {
|
|
97
|
+
for (const item of value) appendChildValue(item);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (typeof value === "string") {
|
|
102
|
+
const segments = takeInterpolatedSegments(value, interpolationCursor);
|
|
103
|
+
if (segments) appendInterpolatedText(segments);
|
|
104
|
+
else el.appendChild(document.createTextNode(value));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (typeof value === "number") {
|
|
109
|
+
el.appendChild(document.createTextNode(String(value)));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (typeof value === "function") {
|
|
114
|
+
appendDynamicChild(value);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (isRod(value)) {
|
|
119
|
+
appendRodText(value);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (value.nodeType) {
|
|
124
|
+
el.appendChild(value);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
appendRodText,
|
|
130
|
+
appendInterpolatedText,
|
|
131
|
+
appendDynamicChild,
|
|
132
|
+
appendChildValue
|
|
133
|
+
};
|
|
134
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* ===============================
|
|
2
|
+
Renderer args parser
|
|
3
|
+
=============================== */
|
|
4
|
+
|
|
5
|
+
function applyRendererArgs(args, options = {}) {
|
|
6
|
+
const {
|
|
7
|
+
el,
|
|
8
|
+
isRod = () => false,
|
|
9
|
+
interpolationCursor = null,
|
|
10
|
+
appendChildValue = () => { },
|
|
11
|
+
appendRodText = () => { },
|
|
12
|
+
appendInterpolatedText = () => { },
|
|
13
|
+
appendDynamicChild = () => { },
|
|
14
|
+
bindProp = () => { }
|
|
15
|
+
} = options;
|
|
16
|
+
|
|
17
|
+
for (const arg of args) {
|
|
18
|
+
if (arg == null) continue;
|
|
19
|
+
|
|
20
|
+
if (Array.isArray(arg)) {
|
|
21
|
+
appendChildValue(arg);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (typeof arg === "string") {
|
|
26
|
+
const segments = takeInterpolatedSegments(arg, interpolationCursor);
|
|
27
|
+
if (segments) appendInterpolatedText(segments);
|
|
28
|
+
else el.appendChild(document.createTextNode(arg));
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (typeof arg === "number") {
|
|
33
|
+
el.appendChild(document.createTextNode(String(arg)));
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (typeof arg === "function") {
|
|
38
|
+
appendDynamicChild(arg);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (isRod(arg)) {
|
|
43
|
+
appendRodText(arg);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (arg.nodeType) {
|
|
48
|
+
el.appendChild(arg);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (typeof arg === "object") {
|
|
53
|
+
for (const [key, value] of Object.entries(arg)) {
|
|
54
|
+
if (typeof value === "string") {
|
|
55
|
+
const segments = takeInterpolatedSegments(value, interpolationCursor);
|
|
56
|
+
if (segments) {
|
|
57
|
+
bindProp(key, () => renderInterpolatedSegments(segments));
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (key === "class") {
|
|
62
|
+
bindProp(key, value);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (key === "style" && typeof value === "object" && value !== null && !isRod(value)) {
|
|
66
|
+
bindProp(key, value);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
bindProp(key, value);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|