fix issue with subwidgets not being mounted/unmounted

This commit is contained in:
Géry Debongnie
2019-01-31 15:14:26 +01:00
parent ed35e0d8e4
commit 7e90aec028
6 changed files with 36 additions and 37 deletions
+13 -2
View File
@@ -230,13 +230,24 @@ export class Widget<T extends WEnv, Props> {
*/
_mount(vnode: VNode, elm: HTMLElement): VNode {
this.__widget__.vnode = patch(elm, vnode);
this.__mount();
return this.__widget__.vnode;
}
__mount() {
if (this.__widget__.isMounted) {
return;
}
if (this.__widget__.parent) {
if (this.__widget__.parent.__widget__.isMounted) {
if (this.__widget__.parent!.__widget__.isMounted) {
this.__widget__.isMounted = true;
this.mounted();
const children = this.__widget__.children;
for (let id in children) {
children[id].__mount();
}
}
}
return this.__widget__.vnode;
}
private visitSubTree(callback: (w: Widget<T, any>) => boolean) {