naive implementation of mounted hook

This commit is contained in:
Géry Debongnie
2019-01-21 14:54:13 +01:00
parent fbf099f1f3
commit cd0ef90075
2 changed files with 21 additions and 3 deletions
+6 -3
View File
@@ -17,7 +17,6 @@ export default class Widget {
name: string = "widget";
template: string = "<div></div>";
vnode: VNode | null = null;
_TEMP: Promise<any>[] | null = null;
parent: Widget | null;
children: Widget[] = [];
@@ -59,6 +58,9 @@ export default class Widget {
if (target) {
target.appendChild(this.el!);
if (document.body.contains(target)) {
this.mounted();
}
}
return vnode;
}
@@ -89,9 +91,10 @@ export default class Widget {
//--------------------------------------------------------------------------
async render(): Promise<VNode> {
this._TEMP = [];
// localized hack to keep track of deferred list
(<any>this)._TEMP = [];
let vnode = this.env!.qweb.render(this.name, this);
await Promise.all(this._TEMP);
await Promise.all((<any>this)._TEMP);
if (!this.el) {
this.el = document.createElement(vnode.sel!);
}