j-templates 7.0.13 → 7.0.14
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/Node/component.d.ts +1 -0
- package/Node/component.js +13 -0
- package/Store/Tree/observableScope.js +1 -3
- package/package.json +1 -1
package/Node/component.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ type ComponentConstructor<D, T, E> = {
|
|
|
29
29
|
};
|
|
30
30
|
export declare namespace Component {
|
|
31
31
|
function ToFunction<D, T, E, P = HTMLElement>(type: string, constructor: ComponentConstructor<D, T, E>, namespace?: string): (config: vComponentConfig<D, E, P>, templates?: T) => vNodeType;
|
|
32
|
+
function Register<D = void, T = void, E = void>(name: string, constructor: ComponentConstructor<D, T, E>): void;
|
|
32
33
|
function Attach(node: any, vnode: vNodeType): vNodeType;
|
|
33
34
|
}
|
|
34
35
|
export {};
|
package/Node/component.js
CHANGED
|
@@ -65,6 +65,19 @@ exports.Component = Component;
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
Component.ToFunction = ToFunction;
|
|
68
|
+
function Register(name, constructor) {
|
|
69
|
+
const componentFunction = ToFunction(`${name}-component`, constructor);
|
|
70
|
+
class WebComponent extends HTMLElement {
|
|
71
|
+
constructor() {
|
|
72
|
+
super();
|
|
73
|
+
const shadowRoot = this.attachShadow({ mode: "open" });
|
|
74
|
+
const node = componentFunction({});
|
|
75
|
+
Attach(shadowRoot, node);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
customElements.define(name, WebComponent);
|
|
79
|
+
}
|
|
80
|
+
Component.Register = Register;
|
|
68
81
|
function Attach(node, vnode) {
|
|
69
82
|
return vNode_1.vNode.Attach(node, vnode);
|
|
70
83
|
}
|
|
@@ -166,9 +166,6 @@ function DirtyScope(scope) {
|
|
|
166
166
|
return;
|
|
167
167
|
if (scope.async) {
|
|
168
168
|
UpdateValue(scope);
|
|
169
|
-
scope.promise.then(function () {
|
|
170
|
-
emitter_1.Emitter.Emit(scope.emitter, scope);
|
|
171
|
-
});
|
|
172
169
|
}
|
|
173
170
|
else
|
|
174
171
|
emitter_1.Emitter.Emit(scope.emitter, scope);
|
|
@@ -199,6 +196,7 @@ function UpdateValue(scope) {
|
|
|
199
196
|
if (scope.async) {
|
|
200
197
|
scope.promise = value.then(function (result) {
|
|
201
198
|
scope.value = result;
|
|
199
|
+
emitter_1.Emitter.Emit(scope.emitter, scope);
|
|
202
200
|
return result;
|
|
203
201
|
});
|
|
204
202
|
}
|