@lordfokas/yrframe 0.4.4 → 0.4.6
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/ComponentFactory.js +4 -1
- package/dist/Facade.d.ts +2 -0
- package/dist/Facade.js +3 -17
- package/package.json +1 -1
package/dist/ComponentFactory.js
CHANGED
|
@@ -9,9 +9,11 @@ export class ComponentFactory {
|
|
|
9
9
|
return children; // Allow returning multiple elements from render()
|
|
10
10
|
// Initialize Element
|
|
11
11
|
let element;
|
|
12
|
+
let facade = undefined;
|
|
12
13
|
if (typeof tag === 'function') { // Construct class based components
|
|
13
14
|
if (tag.prototype instanceof Facade) {
|
|
14
|
-
|
|
15
|
+
facade = new tag(props ?? {});
|
|
16
|
+
element = facade.content();
|
|
15
17
|
}
|
|
16
18
|
else {
|
|
17
19
|
element = new tag(props ?? {});
|
|
@@ -23,6 +25,7 @@ export class ComponentFactory {
|
|
|
23
25
|
}
|
|
24
26
|
// Append children if any
|
|
25
27
|
if (children && children.length > 0) {
|
|
28
|
+
facade?.setInitialChildren(children);
|
|
26
29
|
this.appendChildren(element, ...children);
|
|
27
30
|
}
|
|
28
31
|
return element;
|
package/dist/Facade.d.ts
CHANGED
|
@@ -15,8 +15,10 @@ type FacadeElement = HTMLElement & EventHost & {
|
|
|
15
15
|
export declare class Facade<A extends Attributes> {
|
|
16
16
|
protected readonly node: FacadeElement;
|
|
17
17
|
protected readonly isCustom: boolean;
|
|
18
|
+
protected initialChildren: (string | Node)[];
|
|
18
19
|
protected events(): ComponentEvents;
|
|
19
20
|
constructor(tag: string, props: Partial<A>, defaults?: Partial<A>);
|
|
20
21
|
content(): FacadeElement;
|
|
22
|
+
setInitialChildren(children: (Node | string)[]): void;
|
|
21
23
|
}
|
|
22
24
|
export {};
|
package/dist/Facade.js
CHANGED
|
@@ -9,6 +9,7 @@ const evt = Symbol('evt');
|
|
|
9
9
|
export class Facade {
|
|
10
10
|
node;
|
|
11
11
|
isCustom;
|
|
12
|
+
initialChildren = [];
|
|
12
13
|
events() {
|
|
13
14
|
if (!this.node[evt]) { // Lazily instantiate event manager
|
|
14
15
|
this.node[evt] = new ComponentEvents(this.node);
|
|
@@ -39,23 +40,8 @@ export class Facade {
|
|
|
39
40
|
}
|
|
40
41
|
return this.node;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
connected = false;
|
|
45
|
-
constructor(component) {
|
|
46
|
-
super(component);
|
|
47
|
-
}
|
|
48
|
-
connect() {
|
|
49
|
-
if (this.connected)
|
|
50
|
-
return;
|
|
51
|
-
super.connect();
|
|
52
|
-
this.connected = true;
|
|
53
|
-
}
|
|
54
|
-
disconnect() {
|
|
55
|
-
if (!this.connected)
|
|
56
|
-
return;
|
|
57
|
-
super.disconnect();
|
|
58
|
-
this.connected = false;
|
|
43
|
+
setInitialChildren(children) {
|
|
44
|
+
this.initialChildren = children;
|
|
59
45
|
}
|
|
60
46
|
}
|
|
61
47
|
(function FacadeMutationObserver() {
|