eleva 1.2.17-beta → 1.2.18-beta
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/README.md +27 -15
- package/dist/eleva.cjs.js +343 -158
- package/dist/eleva.cjs.js.map +1 -1
- package/dist/eleva.d.ts +257 -106
- package/dist/eleva.esm.js +343 -158
- package/dist/eleva.esm.js.map +1 -1
- package/dist/eleva.umd.js +343 -158
- package/dist/eleva.umd.js.map +1 -1
- package/dist/eleva.umd.min.js +2 -2
- package/dist/eleva.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/core/Eleva.js +143 -75
- package/src/modules/Emitter.js +23 -7
- package/src/modules/Renderer.js +177 -81
- package/src/modules/Signal.js +10 -7
- package/src/modules/TemplateEngine.js +6 -3
- package/types/core/Eleva.d.ts +164 -68
- package/types/core/Eleva.d.ts.map +1 -1
- package/types/modules/Emitter.d.ts +26 -10
- package/types/modules/Emitter.d.ts.map +1 -1
- package/types/modules/Renderer.d.ts +56 -19
- package/types/modules/Renderer.d.ts.map +1 -1
- package/types/modules/Signal.d.ts +11 -9
- package/types/modules/Signal.d.ts.map +1 -1
- package/types/modules/TemplateEngine.d.ts +8 -5
- package/types/modules/TemplateEngine.d.ts.map +1 -1
package/dist/eleva.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Eleva v1.2.
|
|
1
|
+
/*! Eleva v1.2.18-beta | MIT License | https://elevajs.com */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
class TemplateEngine {
|
|
16
16
|
/**
|
|
17
17
|
* @private {RegExp} Regular expression for matching template expressions in the format {{ expression }}
|
|
18
|
+
* @type {RegExp}
|
|
18
19
|
*/
|
|
19
20
|
static expressionPattern = /\{\{\s*(.*?)\s*\}\}/g;
|
|
20
21
|
|
|
@@ -25,7 +26,7 @@ class TemplateEngine {
|
|
|
25
26
|
* @public
|
|
26
27
|
* @static
|
|
27
28
|
* @param {string} template - The template string to parse.
|
|
28
|
-
* @param {
|
|
29
|
+
* @param {Record<string, unknown>} data - The data context for evaluating expressions.
|
|
29
30
|
* @returns {string} The parsed template with expressions replaced by their values.
|
|
30
31
|
* @example
|
|
31
32
|
* const result = TemplateEngine.parse("{{user.name}} is {{user.age}} years old", {
|
|
@@ -40,12 +41,14 @@ class TemplateEngine {
|
|
|
40
41
|
/**
|
|
41
42
|
* Evaluates an expression in the context of the provided data object.
|
|
42
43
|
* Note: This does not provide a true sandbox and evaluated expressions may access global scope.
|
|
44
|
+
* The use of the `with` statement is necessary for expression evaluation but has security implications.
|
|
45
|
+
* Expressions should be carefully validated before evaluation.
|
|
43
46
|
*
|
|
44
47
|
* @public
|
|
45
48
|
* @static
|
|
46
49
|
* @param {string} expression - The expression to evaluate.
|
|
47
|
-
* @param {
|
|
48
|
-
* @returns {
|
|
50
|
+
* @param {Record<string, unknown>} data - The data context for evaluation.
|
|
51
|
+
* @returns {unknown} The result of the evaluation, or an empty string if evaluation fails.
|
|
49
52
|
* @example
|
|
50
53
|
* const result = TemplateEngine.evaluate("user.name", { user: { name: "John" } }); // Returns: "John"
|
|
51
54
|
* const age = TemplateEngine.evaluate("user.age", { user: { age: 30 } }); // Returns: 30
|
|
@@ -65,6 +68,8 @@ class TemplateEngine {
|
|
|
65
68
|
* @classdesc A reactive data holder that enables fine-grained reactivity in the Eleva framework.
|
|
66
69
|
* Signals notify registered watchers when their value changes, enabling efficient DOM updates
|
|
67
70
|
* through targeted patching rather than full re-renders.
|
|
71
|
+
* Updates are batched using microtasks to prevent multiple synchronous notifications.
|
|
72
|
+
* The class is generic, allowing type-safe handling of any value type T.
|
|
68
73
|
*
|
|
69
74
|
* @example
|
|
70
75
|
* const count = new Signal(0);
|
|
@@ -77,12 +82,12 @@ class Signal {
|
|
|
77
82
|
* Creates a new Signal instance with the specified initial value.
|
|
78
83
|
*
|
|
79
84
|
* @public
|
|
80
|
-
* @param {
|
|
85
|
+
* @param {T} value - The initial value of the signal.
|
|
81
86
|
*/
|
|
82
87
|
constructor(value) {
|
|
83
|
-
/** @private {T} Internal storage for the signal's current value
|
|
88
|
+
/** @private {T} Internal storage for the signal's current value */
|
|
84
89
|
this._value = value;
|
|
85
|
-
/** @private {Set<
|
|
90
|
+
/** @private {Set<(value: T) => void>} Collection of callback functions to be notified when value changes */
|
|
86
91
|
this._watchers = new Set();
|
|
87
92
|
/** @private {boolean} Flag to prevent multiple synchronous watcher notifications and batch updates into microtasks */
|
|
88
93
|
this._pending = false;
|
|
@@ -92,7 +97,7 @@ class Signal {
|
|
|
92
97
|
* Gets the current value of the signal.
|
|
93
98
|
*
|
|
94
99
|
* @public
|
|
95
|
-
* @returns {T} The current value
|
|
100
|
+
* @returns {T} The current value.
|
|
96
101
|
*/
|
|
97
102
|
get value() {
|
|
98
103
|
return this._value;
|
|
@@ -103,7 +108,7 @@ class Signal {
|
|
|
103
108
|
* The notification is batched using microtasks to prevent multiple synchronous updates.
|
|
104
109
|
*
|
|
105
110
|
* @public
|
|
106
|
-
* @param {T} newVal - The new value to set
|
|
111
|
+
* @param {T} newVal - The new value to set.
|
|
107
112
|
* @returns {void}
|
|
108
113
|
*/
|
|
109
114
|
set value(newVal) {
|
|
@@ -117,8 +122,8 @@ class Signal {
|
|
|
117
122
|
* The watcher will receive the new value as its argument.
|
|
118
123
|
*
|
|
119
124
|
* @public
|
|
120
|
-
* @param {
|
|
121
|
-
* @returns {
|
|
125
|
+
* @param {(value: T) => void} fn - The callback function to invoke on value change.
|
|
126
|
+
* @returns {() => boolean} A function to unsubscribe the watcher.
|
|
122
127
|
* @example
|
|
123
128
|
* const unsubscribe = signal.watch((value) => console.log(value));
|
|
124
129
|
* // Later...
|
|
@@ -141,6 +146,7 @@ class Signal {
|
|
|
141
146
|
if (this._pending) return;
|
|
142
147
|
this._pending = true;
|
|
143
148
|
queueMicrotask(() => {
|
|
149
|
+
/** @type {(fn: (value: T) => void) => void} */
|
|
144
150
|
this._watchers.forEach(fn => fn(this._value));
|
|
145
151
|
this._pending = false;
|
|
146
152
|
});
|
|
@@ -152,6 +158,9 @@ class Signal {
|
|
|
152
158
|
* @classdesc A robust event emitter that enables inter-component communication through a publish-subscribe pattern.
|
|
153
159
|
* Components can emit events and listen for events from other components, facilitating loose coupling
|
|
154
160
|
* and reactive updates across the application.
|
|
161
|
+
* Events are handled synchronously in the order they were registered, with proper cleanup
|
|
162
|
+
* of unsubscribed handlers.
|
|
163
|
+
* Event names should follow the format 'namespace:action' (e.g., 'user:login', 'cart:update').
|
|
155
164
|
*
|
|
156
165
|
* @example
|
|
157
166
|
* const emitter = new Emitter();
|
|
@@ -165,18 +174,19 @@ class Emitter {
|
|
|
165
174
|
* @public
|
|
166
175
|
*/
|
|
167
176
|
constructor() {
|
|
168
|
-
/** @private {Map<string, Set<
|
|
177
|
+
/** @private {Map<string, Set<(data: unknown) => void>>} Map of event names to their registered handler functions */
|
|
169
178
|
this._events = new Map();
|
|
170
179
|
}
|
|
171
180
|
|
|
172
181
|
/**
|
|
173
182
|
* Registers an event handler for the specified event name.
|
|
174
183
|
* The handler will be called with the event data when the event is emitted.
|
|
184
|
+
* Event names should follow the format 'namespace:action' for consistency.
|
|
175
185
|
*
|
|
176
186
|
* @public
|
|
177
|
-
* @param {string} event - The name of the event to listen for.
|
|
178
|
-
* @param {
|
|
179
|
-
* @returns {
|
|
187
|
+
* @param {string} event - The name of the event to listen for (e.g., 'user:login').
|
|
188
|
+
* @param {(data: unknown) => void} handler - The callback function to invoke when the event occurs.
|
|
189
|
+
* @returns {() => void} A function to unsubscribe the event handler.
|
|
180
190
|
* @example
|
|
181
191
|
* const unsubscribe = emitter.on('user:login', (user) => console.log(user));
|
|
182
192
|
* // Later...
|
|
@@ -191,11 +201,17 @@ class Emitter {
|
|
|
191
201
|
/**
|
|
192
202
|
* Removes an event handler for the specified event name.
|
|
193
203
|
* If no handler is provided, all handlers for the event are removed.
|
|
204
|
+
* Automatically cleans up empty event sets to prevent memory leaks.
|
|
194
205
|
*
|
|
195
206
|
* @public
|
|
196
|
-
* @param {string} event - The name of the event.
|
|
197
|
-
* @param {
|
|
207
|
+
* @param {string} event - The name of the event to remove handlers from.
|
|
208
|
+
* @param {(data: unknown) => void} [handler] - The specific handler function to remove.
|
|
198
209
|
* @returns {void}
|
|
210
|
+
* @example
|
|
211
|
+
* // Remove a specific handler
|
|
212
|
+
* emitter.off('user:login', loginHandler);
|
|
213
|
+
* // Remove all handlers for an event
|
|
214
|
+
* emitter.off('user:login');
|
|
199
215
|
*/
|
|
200
216
|
off(event, handler) {
|
|
201
217
|
if (!this._events.has(event)) return;
|
|
@@ -212,11 +228,17 @@ class Emitter {
|
|
|
212
228
|
/**
|
|
213
229
|
* Emits an event with the specified data to all registered handlers.
|
|
214
230
|
* Handlers are called synchronously in the order they were registered.
|
|
231
|
+
* If no handlers are registered for the event, the emission is silently ignored.
|
|
215
232
|
*
|
|
216
233
|
* @public
|
|
217
234
|
* @param {string} event - The name of the event to emit.
|
|
218
|
-
* @param {...
|
|
235
|
+
* @param {...unknown} args - Optional arguments to pass to the event handlers.
|
|
219
236
|
* @returns {void}
|
|
237
|
+
* @example
|
|
238
|
+
* // Emit an event with data
|
|
239
|
+
* emitter.emit('user:login', { name: 'John', role: 'admin' });
|
|
240
|
+
* // Emit an event with multiple arguments
|
|
241
|
+
* emitter.emit('cart:update', { items: [] }, { total: 0 });
|
|
220
242
|
*/
|
|
221
243
|
emit(event, ...args) {
|
|
222
244
|
if (!this._events.has(event)) return;
|
|
@@ -224,11 +246,27 @@ class Emitter {
|
|
|
224
246
|
}
|
|
225
247
|
}
|
|
226
248
|
|
|
249
|
+
/**
|
|
250
|
+
* A regular expression to match hyphenated lowercase letters.
|
|
251
|
+
* @private
|
|
252
|
+
* @type {RegExp}
|
|
253
|
+
*/
|
|
254
|
+
const CAMEL_RE = /-([a-z])/g;
|
|
255
|
+
|
|
227
256
|
/**
|
|
228
257
|
* @class 🎨 Renderer
|
|
229
|
-
* @classdesc A DOM renderer that
|
|
230
|
-
*
|
|
231
|
-
*
|
|
258
|
+
* @classdesc A high-performance DOM renderer that implements an optimized direct DOM diffing algorithm.
|
|
259
|
+
*
|
|
260
|
+
* Key features:
|
|
261
|
+
* - Single-pass diffing algorithm for efficient DOM updates
|
|
262
|
+
* - Key-based node reconciliation for optimal performance
|
|
263
|
+
* - Intelligent attribute handling for ARIA, data attributes, and boolean properties
|
|
264
|
+
* - Preservation of special Eleva-managed instances and style elements
|
|
265
|
+
* - Memory-efficient with reusable temporary containers
|
|
266
|
+
*
|
|
267
|
+
* The renderer is designed to minimize DOM operations while maintaining
|
|
268
|
+
* exact attribute synchronization and proper node identity preservation.
|
|
269
|
+
* It's particularly optimized for frequent updates and complex DOM structures.
|
|
232
270
|
*
|
|
233
271
|
* @example
|
|
234
272
|
* const renderer = new Renderer();
|
|
@@ -238,121 +276,173 @@ class Emitter {
|
|
|
238
276
|
*/
|
|
239
277
|
class Renderer {
|
|
240
278
|
/**
|
|
241
|
-
* Creates a new Renderer instance
|
|
279
|
+
* Creates a new Renderer instance.
|
|
242
280
|
* @public
|
|
243
281
|
*/
|
|
244
282
|
constructor() {
|
|
245
|
-
/**
|
|
283
|
+
/**
|
|
284
|
+
* A temporary container to hold the new HTML content while diffing.
|
|
285
|
+
* @private
|
|
286
|
+
* @type {HTMLElement}
|
|
287
|
+
*/
|
|
246
288
|
this._tempContainer = document.createElement("div");
|
|
247
289
|
}
|
|
248
290
|
|
|
249
291
|
/**
|
|
250
|
-
* Patches the DOM of
|
|
251
|
-
* Efficiently updates the DOM by parsing new HTML into a reusable container
|
|
252
|
-
* and applying only the necessary changes.
|
|
292
|
+
* Patches the DOM of the given container with the provided HTML string.
|
|
253
293
|
*
|
|
254
294
|
* @public
|
|
255
|
-
* @param {HTMLElement} container - The container
|
|
256
|
-
* @param {string} newHtml - The new HTML
|
|
295
|
+
* @param {HTMLElement} container - The container whose DOM will be patched.
|
|
296
|
+
* @param {string} newHtml - The new HTML string.
|
|
297
|
+
* @throws {TypeError} If the container is not an HTMLElement or newHtml is not a string.
|
|
298
|
+
* @throws {Error} If the DOM patching fails.
|
|
257
299
|
* @returns {void}
|
|
258
|
-
* @throws {Error} If container is not an HTMLElement, newHtml is not a string, or patching fails.
|
|
259
300
|
*/
|
|
260
301
|
patchDOM(container, newHtml) {
|
|
261
302
|
if (!(container instanceof HTMLElement)) {
|
|
262
|
-
throw new
|
|
303
|
+
throw new TypeError("Container must be an HTMLElement");
|
|
263
304
|
}
|
|
264
305
|
if (typeof newHtml !== "string") {
|
|
265
|
-
throw new
|
|
306
|
+
throw new TypeError("newHtml must be a string");
|
|
266
307
|
}
|
|
267
308
|
try {
|
|
268
|
-
// Directly set new HTML, replacing any existing content
|
|
269
309
|
this._tempContainer.innerHTML = newHtml;
|
|
270
310
|
this._diff(container, this._tempContainer);
|
|
271
|
-
} catch {
|
|
272
|
-
throw new Error(
|
|
311
|
+
} catch (error) {
|
|
312
|
+
throw new Error(`Failed to patch DOM: ${error.message}`);
|
|
273
313
|
}
|
|
274
314
|
}
|
|
275
315
|
|
|
276
316
|
/**
|
|
277
|
-
*
|
|
278
|
-
* This method recursively compares nodes and their attributes, applying only
|
|
279
|
-
* the necessary changes to minimize DOM operations.
|
|
317
|
+
* Performs a diff between two DOM nodes and patches the old node to match the new node.
|
|
280
318
|
*
|
|
281
319
|
* @private
|
|
282
|
-
* @param {
|
|
283
|
-
* @param {
|
|
320
|
+
* @param {Node} oldParent - The old parent node to be patched.
|
|
321
|
+
* @param {Node} newParent - The new parent node to compare.
|
|
284
322
|
* @returns {void}
|
|
285
323
|
*/
|
|
286
324
|
_diff(oldParent, newParent) {
|
|
287
|
-
if (oldParent.isEqualNode(newParent)) return;
|
|
288
|
-
const oldChildren = oldParent.childNodes;
|
|
289
|
-
const newChildren = newParent.childNodes;
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
325
|
+
if (oldParent === newParent || oldParent.isEqualNode?.(newParent)) return;
|
|
326
|
+
const oldChildren = Array.from(oldParent.childNodes);
|
|
327
|
+
const newChildren = Array.from(newParent.childNodes);
|
|
328
|
+
let oldStartIdx = 0,
|
|
329
|
+
newStartIdx = 0;
|
|
330
|
+
let oldEndIdx = oldChildren.length - 1;
|
|
331
|
+
let newEndIdx = newChildren.length - 1;
|
|
332
|
+
let oldKeyMap = null;
|
|
333
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
334
|
+
let oldStartNode = oldChildren[oldStartIdx];
|
|
335
|
+
let newStartNode = newChildren[newStartIdx];
|
|
336
|
+
if (!oldStartNode) {
|
|
337
|
+
oldStartIdx++;
|
|
295
338
|
continue;
|
|
296
339
|
}
|
|
297
|
-
if (!
|
|
298
|
-
|
|
340
|
+
if (!newStartNode) {
|
|
341
|
+
newStartIdx++;
|
|
299
342
|
continue;
|
|
300
343
|
}
|
|
301
|
-
if (
|
|
302
|
-
|
|
303
|
-
|
|
344
|
+
if (this._keysMatch(oldStartNode, newStartNode)) {
|
|
345
|
+
this._patchNode(oldStartNode, newStartNode);
|
|
346
|
+
oldStartIdx++;
|
|
347
|
+
newStartIdx++;
|
|
348
|
+
} else {
|
|
349
|
+
oldKeyMap ??= this._createKeyMap(oldChildren, oldStartIdx, oldEndIdx);
|
|
350
|
+
const newKey = newStartNode.nodeType === Node.ELEMENT_NODE ? newStartNode.getAttribute("key") : null;
|
|
351
|
+
const moveIndex = newKey ? oldKeyMap.get(newKey) : undefined;
|
|
352
|
+
const oldNodeToMove = moveIndex !== undefined ? oldChildren[moveIndex] : null;
|
|
353
|
+
if (oldNodeToMove) {
|
|
354
|
+
this._patchNode(oldNodeToMove, newStartNode);
|
|
355
|
+
oldParent.insertBefore(oldNodeToMove, oldStartNode);
|
|
356
|
+
if (moveIndex !== undefined) oldChildren[moveIndex] = null;
|
|
357
|
+
} else {
|
|
358
|
+
oldParent.insertBefore(newStartNode.cloneNode(true), oldStartNode);
|
|
304
359
|
}
|
|
305
|
-
|
|
306
|
-
continue;
|
|
360
|
+
newStartIdx++;
|
|
307
361
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Cleanup
|
|
365
|
+
if (oldStartIdx > oldEndIdx) {
|
|
366
|
+
const refNode = newChildren[newEndIdx + 1] ? oldChildren[oldStartIdx] : null;
|
|
367
|
+
for (let i = newStartIdx; i <= newEndIdx; i++) {
|
|
368
|
+
if (newChildren[i]) oldParent.insertBefore(newChildren[i].cloneNode(true), refNode);
|
|
312
369
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
if (
|
|
317
|
-
oldParent.
|
|
318
|
-
continue;
|
|
370
|
+
} else if (newStartIdx > newEndIdx) {
|
|
371
|
+
for (let i = oldStartIdx; i <= oldEndIdx; i++) {
|
|
372
|
+
const node = oldChildren[i];
|
|
373
|
+
if (node && !(node.nodeName === "STYLE" && node.hasAttribute("data-e-style"))) {
|
|
374
|
+
oldParent.removeChild(node);
|
|
319
375
|
}
|
|
320
|
-
this._updateAttributes(oldNode, newNode);
|
|
321
|
-
this._diff(oldNode, newNode);
|
|
322
|
-
} else if (oldNode.nodeType === Node.TEXT_NODE && oldNode.nodeValue !== newNode.nodeValue) {
|
|
323
|
-
oldNode.nodeValue = newNode.nodeValue;
|
|
324
376
|
}
|
|
325
377
|
}
|
|
326
378
|
}
|
|
327
379
|
|
|
328
380
|
/**
|
|
329
|
-
*
|
|
330
|
-
*
|
|
381
|
+
* Checks if the node types match.
|
|
382
|
+
*
|
|
383
|
+
* @private
|
|
384
|
+
* @param {Node} oldNode - The old node.
|
|
385
|
+
* @param {Node} newNode - The new node.
|
|
386
|
+
* @returns {boolean} True if the nodes match, false otherwise.
|
|
387
|
+
*/
|
|
388
|
+
_keysMatch(oldNode, newNode) {
|
|
389
|
+
if (oldNode.nodeType !== Node.ELEMENT_NODE) return true;
|
|
390
|
+
const oldKey = oldNode.getAttribute("key");
|
|
391
|
+
const newKey = newNode.getAttribute("key");
|
|
392
|
+
return oldKey === newKey;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Patches a node.
|
|
397
|
+
*
|
|
398
|
+
* @private
|
|
399
|
+
* @param {Node} oldNode - The old node to patch.
|
|
400
|
+
* @param {Node} newNode - The new node to patch.
|
|
401
|
+
* @returns {void}
|
|
402
|
+
*/
|
|
403
|
+
_patchNode(oldNode, newNode) {
|
|
404
|
+
if (oldNode?._eleva_instance) return;
|
|
405
|
+
if (oldNode.nodeType !== newNode.nodeType || oldNode.nodeName !== newNode.nodeName) {
|
|
406
|
+
oldNode.replaceWith(newNode.cloneNode(true));
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
if (oldNode.nodeType === Node.ELEMENT_NODE) {
|
|
410
|
+
const oldEl = oldNode;
|
|
411
|
+
const newEl = newNode;
|
|
412
|
+
this._updateAttributes(oldEl, newEl);
|
|
413
|
+
this._diff(oldEl, newEl);
|
|
414
|
+
} else if (oldNode.nodeType === Node.TEXT_NODE && oldNode.nodeValue !== newNode.nodeValue) {
|
|
415
|
+
oldNode.nodeValue = newNode.nodeValue;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Updates the attributes of an element.
|
|
331
421
|
*
|
|
332
422
|
* @private
|
|
333
|
-
* @param {HTMLElement} oldEl - The element to update.
|
|
334
|
-
* @param {HTMLElement} newEl - The element
|
|
423
|
+
* @param {HTMLElement} oldEl - The old element to update.
|
|
424
|
+
* @param {HTMLElement} newEl - The new element to update.
|
|
335
425
|
* @returns {void}
|
|
336
426
|
*/
|
|
337
427
|
_updateAttributes(oldEl, newEl) {
|
|
338
428
|
const oldAttrs = oldEl.attributes;
|
|
339
429
|
const newAttrs = newEl.attributes;
|
|
340
430
|
|
|
341
|
-
//
|
|
342
|
-
for (
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
if (oldEl.getAttribute(name) === value) continue;
|
|
431
|
+
// Single pass for new/updated attributes
|
|
432
|
+
for (let i = 0; i < newAttrs.length; i++) {
|
|
433
|
+
const {
|
|
434
|
+
name,
|
|
435
|
+
value
|
|
436
|
+
} = newAttrs[i];
|
|
437
|
+
if (name[0] === "@" || oldEl.getAttribute(name) === value) continue;
|
|
348
438
|
oldEl.setAttribute(name, value);
|
|
349
|
-
if (name
|
|
350
|
-
const
|
|
351
|
-
oldEl[
|
|
352
|
-
} else if (name
|
|
439
|
+
if (name[0] === "a" && name[4] === "-") {
|
|
440
|
+
const s = name.slice(5);
|
|
441
|
+
oldEl["aria" + s.replace(CAMEL_RE, (_, l) => l.toUpperCase())] = value;
|
|
442
|
+
} else if (name[0] === "d" && name[3] === "-") {
|
|
353
443
|
oldEl.dataset[name.slice(5)] = value;
|
|
354
444
|
} else {
|
|
355
|
-
const prop = name.
|
|
445
|
+
const prop = name.includes("-") ? name.replace(CAMEL_RE, (_, l) => l.toUpperCase()) : name;
|
|
356
446
|
if (prop in oldEl) {
|
|
357
447
|
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(oldEl), prop);
|
|
358
448
|
const isBoolean = typeof oldEl[prop] === "boolean" || descriptor?.get && typeof descriptor.get.call(oldEl) === "boolean";
|
|
@@ -365,47 +455,109 @@ class Renderer {
|
|
|
365
455
|
}
|
|
366
456
|
}
|
|
367
457
|
|
|
368
|
-
// Remove
|
|
369
|
-
for (
|
|
370
|
-
name
|
|
371
|
-
} of oldAttrs) {
|
|
458
|
+
// Remove any attributes no longer present
|
|
459
|
+
for (let i = oldAttrs.length - 1; i >= 0; i--) {
|
|
460
|
+
const name = oldAttrs[i].name;
|
|
372
461
|
if (!newEl.hasAttribute(name)) {
|
|
373
462
|
oldEl.removeAttribute(name);
|
|
374
463
|
}
|
|
375
464
|
}
|
|
376
465
|
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Creates a key map for the children of a parent node.
|
|
469
|
+
*
|
|
470
|
+
* @private
|
|
471
|
+
* @param {Array<Node>} children - The children of the parent node.
|
|
472
|
+
* @param {number} start - The start index of the children.
|
|
473
|
+
* @param {number} end - The end index of the children.
|
|
474
|
+
* @returns {Map<string, number>} A map of key to child index.
|
|
475
|
+
*/
|
|
476
|
+
_createKeyMap(children, start, end) {
|
|
477
|
+
const map = new Map();
|
|
478
|
+
for (let i = start; i <= end; i++) {
|
|
479
|
+
const child = children[i];
|
|
480
|
+
if (child?.nodeType === Node.ELEMENT_NODE) {
|
|
481
|
+
const key = child.getAttribute("key");
|
|
482
|
+
if (key) map.set(key, i);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return map;
|
|
486
|
+
}
|
|
377
487
|
}
|
|
378
488
|
|
|
379
489
|
/**
|
|
380
490
|
* @typedef {Object} ComponentDefinition
|
|
381
|
-
* @property {function(
|
|
491
|
+
* @property {function(ComponentContext): (Record<string, unknown>|Promise<Record<string, unknown>>)} [setup]
|
|
382
492
|
* Optional setup function that initializes the component's state and returns reactive data
|
|
383
|
-
* @property {(function(
|
|
493
|
+
* @property {(function(ComponentContext): string|Promise<string>)} template
|
|
384
494
|
* Required function that defines the component's HTML structure
|
|
385
|
-
* @property {(function(
|
|
495
|
+
* @property {(function(ComponentContext): string)|string} [style]
|
|
386
496
|
* Optional function or string that provides component-scoped CSS styles
|
|
387
|
-
* @property {
|
|
497
|
+
* @property {Record<string, ComponentDefinition>} [children]
|
|
388
498
|
* Optional object defining nested child components
|
|
389
499
|
*/
|
|
390
500
|
|
|
391
501
|
/**
|
|
392
|
-
* @typedef {Object}
|
|
393
|
-
* @property {
|
|
394
|
-
*
|
|
395
|
-
* @property {
|
|
396
|
-
*
|
|
502
|
+
* @typedef {Object} ComponentContext
|
|
503
|
+
* @property {Record<string, unknown>} props
|
|
504
|
+
* Component properties passed during mounting
|
|
505
|
+
* @property {Emitter} emitter
|
|
506
|
+
* Event emitter instance for component event handling
|
|
507
|
+
* @property {function<T>(value: T): Signal<T>} signal
|
|
508
|
+
* Factory function to create reactive Signal instances
|
|
509
|
+
* @property {function(LifecycleHookContext): Promise<void>} [onBeforeMount]
|
|
510
|
+
* Hook called before component mounting
|
|
511
|
+
* @property {function(LifecycleHookContext): Promise<void>} [onMount]
|
|
512
|
+
* Hook called after component mounting
|
|
513
|
+
* @property {function(LifecycleHookContext): Promise<void>} [onBeforeUpdate]
|
|
514
|
+
* Hook called before component update
|
|
515
|
+
* @property {function(LifecycleHookContext): Promise<void>} [onUpdate]
|
|
516
|
+
* Hook called after component update
|
|
517
|
+
* @property {function(UnmountHookContext): Promise<void>} [onUnmount]
|
|
518
|
+
* Hook called during component unmounting
|
|
519
|
+
*/
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* @typedef {Object} LifecycleHookContext
|
|
523
|
+
* @property {HTMLElement} container
|
|
524
|
+
* The DOM element where the component is mounted
|
|
525
|
+
* @property {ComponentContext} context
|
|
526
|
+
* The component's reactive state and context data
|
|
527
|
+
*/
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* @typedef {Object} UnmountHookContext
|
|
531
|
+
* @property {HTMLElement} container
|
|
532
|
+
* The DOM element where the component is mounted
|
|
533
|
+
* @property {ComponentContext} context
|
|
534
|
+
* The component's reactive state and context data
|
|
535
|
+
* @property {{
|
|
536
|
+
* watchers: Array<() => void>, // Signal watcher cleanup functions
|
|
537
|
+
* listeners: Array<() => void>, // Event listener cleanup functions
|
|
538
|
+
* children: Array<MountResult> // Child component instances
|
|
539
|
+
* }} cleanup
|
|
540
|
+
* Object containing cleanup functions and instances
|
|
397
541
|
*/
|
|
398
542
|
|
|
399
543
|
/**
|
|
400
544
|
* @typedef {Object} MountResult
|
|
401
545
|
* @property {HTMLElement} container
|
|
402
546
|
* The DOM element where the component is mounted
|
|
403
|
-
* @property {
|
|
547
|
+
* @property {ComponentContext} data
|
|
404
548
|
* The component's reactive state and context data
|
|
405
|
-
* @property {function(): void} unmount
|
|
549
|
+
* @property {function(): Promise<void>} unmount
|
|
406
550
|
* Function to clean up and unmount the component
|
|
407
551
|
*/
|
|
408
552
|
|
|
553
|
+
/**
|
|
554
|
+
* @typedef {Object} ElevaPlugin
|
|
555
|
+
* @property {function(Eleva, Record<string, unknown>): void} install
|
|
556
|
+
* Function that installs the plugin into the Eleva instance
|
|
557
|
+
* @property {string} name
|
|
558
|
+
* Unique identifier name for the plugin
|
|
559
|
+
*/
|
|
560
|
+
|
|
409
561
|
/**
|
|
410
562
|
* @class 🧩 Eleva
|
|
411
563
|
* @classdesc A modern, signal-based component runtime framework that provides lifecycle hooks,
|
|
@@ -413,12 +565,26 @@ class Renderer {
|
|
|
413
565
|
* event handling, and DOM rendering with a focus on performance and developer experience.
|
|
414
566
|
*
|
|
415
567
|
* @example
|
|
568
|
+
* // Basic component creation and mounting
|
|
416
569
|
* const app = new Eleva("myApp");
|
|
417
570
|
* app.component("myComponent", {
|
|
418
|
-
*
|
|
419
|
-
*
|
|
571
|
+
* setup: (ctx) => ({ count: ctx.signal(0) }),
|
|
572
|
+
* template: (ctx) => `<div>Hello ${ctx.props.name}</div>`
|
|
420
573
|
* });
|
|
421
574
|
* app.mount(document.getElementById("app"), "myComponent", { name: "World" });
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* // Using lifecycle hooks
|
|
578
|
+
* app.component("lifecycleDemo", {
|
|
579
|
+
* setup: () => {
|
|
580
|
+
* return {
|
|
581
|
+
* onMount: ({ container, context }) => {
|
|
582
|
+
* console.log('Component mounted!');
|
|
583
|
+
* }
|
|
584
|
+
* };
|
|
585
|
+
* },
|
|
586
|
+
* template: `<div>Lifecycle Demo</div>`
|
|
587
|
+
* });
|
|
422
588
|
*/
|
|
423
589
|
class Eleva {
|
|
424
590
|
/**
|
|
@@ -426,13 +592,24 @@ class Eleva {
|
|
|
426
592
|
*
|
|
427
593
|
* @public
|
|
428
594
|
* @param {string} name - The unique identifier name for this Eleva instance.
|
|
429
|
-
* @param {
|
|
595
|
+
* @param {Record<string, unknown>} [config={}] - Optional configuration object for the instance.
|
|
430
596
|
* May include framework-wide settings and default behaviors.
|
|
597
|
+
* @throws {Error} If the name is not provided or is not a string.
|
|
598
|
+
* @returns {Eleva} A new Eleva instance.
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* const app = new Eleva("myApp");
|
|
602
|
+
* app.component("myComponent", {
|
|
603
|
+
* setup: (ctx) => ({ count: ctx.signal(0) }),
|
|
604
|
+
* template: (ctx) => `<div>Hello ${ctx.props.name}!</div>`
|
|
605
|
+
* });
|
|
606
|
+
* app.mount(document.getElementById("app"), "myComponent", { name: "World" });
|
|
607
|
+
*
|
|
431
608
|
*/
|
|
432
609
|
constructor(name, config = {}) {
|
|
433
610
|
/** @public {string} The unique identifier name for this Eleva instance */
|
|
434
611
|
this.name = name;
|
|
435
|
-
/** @public {Object<string,
|
|
612
|
+
/** @public {Object<string, unknown>} Optional configuration object for the Eleva instance */
|
|
436
613
|
this.config = config;
|
|
437
614
|
/** @public {Emitter} Instance of the event emitter for handling component events */
|
|
438
615
|
this.emitter = new Emitter();
|
|
@@ -445,8 +622,6 @@ class Eleva {
|
|
|
445
622
|
this._components = new Map();
|
|
446
623
|
/** @private {Map<string, ElevaPlugin>} Collection of installed plugin instances by name */
|
|
447
624
|
this._plugins = new Map();
|
|
448
|
-
/** @private {string[]} Array of lifecycle hook names supported by components */
|
|
449
|
-
this._lifecycleHooks = ["onBeforeMount", "onMount", "onBeforeUpdate", "onUpdate", "onUnmount"];
|
|
450
625
|
/** @private {boolean} Flag indicating if the root component is currently mounted */
|
|
451
626
|
this._isMounted = false;
|
|
452
627
|
}
|
|
@@ -458,7 +633,7 @@ class Eleva {
|
|
|
458
633
|
*
|
|
459
634
|
* @public
|
|
460
635
|
* @param {ElevaPlugin} plugin - The plugin object which must have an `install` function.
|
|
461
|
-
* @param {Object<string,
|
|
636
|
+
* @param {Object<string, unknown>} [options={}] - Optional configuration options for the plugin.
|
|
462
637
|
* @returns {Eleva} The Eleva instance (for method chaining).
|
|
463
638
|
* @example
|
|
464
639
|
* app.use(myPlugin, { option1: "value1" });
|
|
@@ -497,7 +672,7 @@ class Eleva {
|
|
|
497
672
|
* @public
|
|
498
673
|
* @param {HTMLElement} container - The DOM element where the component will be mounted.
|
|
499
674
|
* @param {string|ComponentDefinition} compName - The name of the registered component or a direct component definition.
|
|
500
|
-
* @param {Object<string,
|
|
675
|
+
* @param {Object<string, unknown>} [props={}] - Optional properties to pass to the component.
|
|
501
676
|
* @returns {Promise<MountResult>}
|
|
502
677
|
* A Promise that resolves to an object containing:
|
|
503
678
|
* - container: The mounted component's container element
|
|
@@ -531,21 +706,12 @@ class Eleva {
|
|
|
531
706
|
children
|
|
532
707
|
} = definition;
|
|
533
708
|
|
|
534
|
-
/**
|
|
535
|
-
* Creates the initial context object for the component instance.
|
|
536
|
-
* This context provides core functionality and will be merged with setup data.
|
|
537
|
-
* @type {Object<string, any>}
|
|
538
|
-
* @property {Object<string, any>} props - Component properties passed during mounting
|
|
539
|
-
* @property {Emitter} emitter - Event emitter instance for component event handling
|
|
540
|
-
* @property {function(any): Signal} signal - Factory function to create reactive Signal instances
|
|
541
|
-
* @property {Object<string, function(): void>} ...lifecycleHooks - Prepared lifecycle hook functions
|
|
542
|
-
*/
|
|
709
|
+
/** @type {ComponentContext} */
|
|
543
710
|
const context = {
|
|
544
711
|
props,
|
|
545
712
|
emitter: this.emitter,
|
|
546
|
-
/** @type {(v:
|
|
547
|
-
signal: v => new this.signal(v)
|
|
548
|
-
...this._prepareLifecycleHooks()
|
|
713
|
+
/** @type {(v: unknown) => Signal<unknown>} */
|
|
714
|
+
signal: v => new this.signal(v)
|
|
549
715
|
};
|
|
550
716
|
|
|
551
717
|
/**
|
|
@@ -556,30 +722,38 @@ class Eleva {
|
|
|
556
722
|
* 3. Rendering the component
|
|
557
723
|
* 4. Managing component lifecycle
|
|
558
724
|
*
|
|
559
|
-
* @param {Object<string,
|
|
725
|
+
* @param {Object<string, unknown>} data - Data returned from the component's setup function
|
|
560
726
|
* @returns {Promise<MountResult>} An object containing:
|
|
561
727
|
* - container: The mounted component's container element
|
|
562
728
|
* - data: The component's reactive state and context
|
|
563
729
|
* - unmount: Function to clean up and unmount the component
|
|
564
730
|
*/
|
|
565
731
|
const processMount = async data => {
|
|
566
|
-
/** @type {
|
|
732
|
+
/** @type {ComponentContext} */
|
|
567
733
|
const mergedContext = {
|
|
568
734
|
...context,
|
|
569
735
|
...data
|
|
570
736
|
};
|
|
571
737
|
/** @type {Array<() => void>} */
|
|
572
|
-
const
|
|
738
|
+
const watchers = [];
|
|
573
739
|
/** @type {Array<MountResult>} */
|
|
574
740
|
const childInstances = [];
|
|
575
741
|
/** @type {Array<() => void>} */
|
|
576
|
-
const
|
|
742
|
+
const listeners = [];
|
|
577
743
|
|
|
578
744
|
// Execute before hooks
|
|
579
745
|
if (!this._isMounted) {
|
|
580
|
-
|
|
746
|
+
/** @type {LifecycleHookContext} */
|
|
747
|
+
await mergedContext.onBeforeMount?.({
|
|
748
|
+
container,
|
|
749
|
+
context: mergedContext
|
|
750
|
+
});
|
|
581
751
|
} else {
|
|
582
|
-
|
|
752
|
+
/** @type {LifecycleHookContext} */
|
|
753
|
+
await mergedContext.onBeforeUpdate?.({
|
|
754
|
+
container,
|
|
755
|
+
context: mergedContext
|
|
756
|
+
});
|
|
583
757
|
}
|
|
584
758
|
|
|
585
759
|
/**
|
|
@@ -592,14 +766,22 @@ class Eleva {
|
|
|
592
766
|
const templateResult = typeof template === "function" ? await template(mergedContext) : template;
|
|
593
767
|
const newHtml = TemplateEngine.parse(templateResult, mergedContext);
|
|
594
768
|
this.renderer.patchDOM(container, newHtml);
|
|
595
|
-
this._processEvents(container, mergedContext,
|
|
769
|
+
this._processEvents(container, mergedContext, listeners);
|
|
596
770
|
if (style) this._injectStyles(container, compName, style, mergedContext);
|
|
597
771
|
if (children) await this._mountComponents(container, children, childInstances);
|
|
598
772
|
if (!this._isMounted) {
|
|
599
|
-
|
|
773
|
+
/** @type {LifecycleHookContext} */
|
|
774
|
+
await mergedContext.onMount?.({
|
|
775
|
+
container,
|
|
776
|
+
context: mergedContext
|
|
777
|
+
});
|
|
600
778
|
this._isMounted = true;
|
|
601
779
|
} else {
|
|
602
|
-
|
|
780
|
+
/** @type {LifecycleHookContext} */
|
|
781
|
+
await mergedContext.onUpdate?.({
|
|
782
|
+
container,
|
|
783
|
+
context: mergedContext
|
|
784
|
+
});
|
|
603
785
|
}
|
|
604
786
|
};
|
|
605
787
|
|
|
@@ -609,7 +791,7 @@ class Eleva {
|
|
|
609
791
|
* Stores unsubscribe functions to clean up watchers when component unmounts.
|
|
610
792
|
*/
|
|
611
793
|
for (const val of Object.values(data)) {
|
|
612
|
-
if (val instanceof Signal)
|
|
794
|
+
if (val instanceof Signal) watchers.push(val.watch(render));
|
|
613
795
|
}
|
|
614
796
|
await render();
|
|
615
797
|
const instance = {
|
|
@@ -620,11 +802,20 @@ class Eleva {
|
|
|
620
802
|
*
|
|
621
803
|
* @returns {void}
|
|
622
804
|
*/
|
|
623
|
-
unmount: () => {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
805
|
+
unmount: async () => {
|
|
806
|
+
/** @type {UnmountHookContext} */
|
|
807
|
+
await mergedContext.onUnmount?.({
|
|
808
|
+
container,
|
|
809
|
+
context: mergedContext,
|
|
810
|
+
cleanup: {
|
|
811
|
+
watchers: watchers,
|
|
812
|
+
listeners: listeners,
|
|
813
|
+
children: childInstances
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
for (const fn of watchers) fn();
|
|
817
|
+
for (const fn of listeners) fn();
|
|
818
|
+
for (const child of childInstances) await child.unmount();
|
|
628
819
|
container.innerHTML = "";
|
|
629
820
|
delete container._eleva_instance;
|
|
630
821
|
}
|
|
@@ -638,47 +829,37 @@ class Eleva {
|
|
|
638
829
|
return await processMount(setupResult);
|
|
639
830
|
}
|
|
640
831
|
|
|
641
|
-
/**
|
|
642
|
-
* Prepares default no-operation lifecycle hook functions for a component.
|
|
643
|
-
* These hooks will be called at various stages of the component's lifecycle.
|
|
644
|
-
*
|
|
645
|
-
* @private
|
|
646
|
-
* @returns {Object<string, function(): void>} An object mapping lifecycle hook names to empty functions.
|
|
647
|
-
* The returned object will be merged with the component's context.
|
|
648
|
-
*/
|
|
649
|
-
_prepareLifecycleHooks() {
|
|
650
|
-
/** @type {Object<string, () => void>} */
|
|
651
|
-
const hooks = {};
|
|
652
|
-
for (const hook of this._lifecycleHooks) {
|
|
653
|
-
hooks[hook] = () => {};
|
|
654
|
-
}
|
|
655
|
-
return hooks;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
832
|
/**
|
|
659
833
|
* Processes DOM elements for event binding based on attributes starting with "@".
|
|
660
834
|
* This method handles the event delegation system and ensures proper cleanup of event listeners.
|
|
661
835
|
*
|
|
662
836
|
* @private
|
|
663
837
|
* @param {HTMLElement} container - The container element in which to search for event attributes.
|
|
664
|
-
* @param {
|
|
665
|
-
* @param {Array<
|
|
838
|
+
* @param {ComponentContext} context - The current component context containing event handler definitions.
|
|
839
|
+
* @param {Array<() => void>} listeners - Array to collect cleanup functions for each event listener.
|
|
666
840
|
* @returns {void}
|
|
667
841
|
*/
|
|
668
|
-
_processEvents(container, context,
|
|
842
|
+
_processEvents(container, context, listeners) {
|
|
843
|
+
/** @type {NodeListOf<Element>} */
|
|
669
844
|
const elements = container.querySelectorAll("*");
|
|
670
845
|
for (const el of elements) {
|
|
846
|
+
/** @type {NamedNodeMap} */
|
|
671
847
|
const attrs = el.attributes;
|
|
672
848
|
for (let i = 0; i < attrs.length; i++) {
|
|
849
|
+
/** @type {Attr} */
|
|
673
850
|
const attr = attrs[i];
|
|
674
851
|
if (!attr.name.startsWith("@")) continue;
|
|
852
|
+
|
|
853
|
+
/** @type {keyof HTMLElementEventMap} */
|
|
675
854
|
const event = attr.name.slice(1);
|
|
855
|
+
/** @type {string} */
|
|
676
856
|
const handlerName = attr.value;
|
|
857
|
+
/** @type {(event: Event) => void} */
|
|
677
858
|
const handler = context[handlerName] || TemplateEngine.evaluate(handlerName, context);
|
|
678
859
|
if (typeof handler === "function") {
|
|
679
860
|
el.addEventListener(event, handler);
|
|
680
861
|
el.removeAttribute(attr.name);
|
|
681
|
-
|
|
862
|
+
listeners.push(() => el.removeEventListener(event, handler));
|
|
682
863
|
}
|
|
683
864
|
}
|
|
684
865
|
}
|
|
@@ -691,12 +872,14 @@ class Eleva {
|
|
|
691
872
|
* @private
|
|
692
873
|
* @param {HTMLElement} container - The container element where styles should be injected.
|
|
693
874
|
* @param {string} compName - The component name used to identify the style element.
|
|
694
|
-
* @param {(function(
|
|
695
|
-
* @param {
|
|
875
|
+
* @param {(function(ComponentContext): string)|string} styleDef - The component's style definition (function or string).
|
|
876
|
+
* @param {ComponentContext} context - The current component context for style interpolation.
|
|
696
877
|
* @returns {void}
|
|
697
878
|
*/
|
|
698
879
|
_injectStyles(container, compName, styleDef, context) {
|
|
880
|
+
/** @type {string} */
|
|
699
881
|
const newStyle = typeof styleDef === "function" ? TemplateEngine.parse(styleDef(context), context) : styleDef;
|
|
882
|
+
/** @type {HTMLStyleElement|null} */
|
|
700
883
|
let styleEl = container.querySelector(`style[data-e-style="${compName}"]`);
|
|
701
884
|
if (styleEl && styleEl.textContent === newStyle) return;
|
|
702
885
|
if (!styleEl) {
|
|
@@ -714,7 +897,7 @@ class Eleva {
|
|
|
714
897
|
* @private
|
|
715
898
|
* @param {HTMLElement} element - The DOM element to extract props from
|
|
716
899
|
* @param {string} prefix - The prefix to look for in attributes
|
|
717
|
-
* @returns {
|
|
900
|
+
* @returns {Record<string, string>} An object containing the extracted props
|
|
718
901
|
* @example
|
|
719
902
|
* // For an element with attributes:
|
|
720
903
|
* // <div :name="John" :age="25">
|
|
@@ -760,7 +943,9 @@ class Eleva {
|
|
|
760
943
|
if (!selector) continue;
|
|
761
944
|
for (const el of container.querySelectorAll(selector)) {
|
|
762
945
|
if (!(el instanceof HTMLElement)) continue;
|
|
946
|
+
/** @type {Record<string, string>} */
|
|
763
947
|
const props = this._extractProps(el, ":");
|
|
948
|
+
/** @type {MountResult} */
|
|
764
949
|
const instance = await this.mount(el, component, props);
|
|
765
950
|
if (instance && !childInstances.includes(instance)) {
|
|
766
951
|
childInstances.push(instance);
|