call mounted recursively on all children

This commit is contained in:
Géry Debongnie
2019-01-21 16:26:51 +01:00
parent 526555fd21
commit a357ff6b37
2 changed files with 35 additions and 2 deletions
+8 -1
View File
@@ -59,7 +59,7 @@ export default class Widget {
if (target) {
target.appendChild(this.el!);
if (document.body.contains(target)) {
this.mounted();
this.visitSubTree(w => w.mounted())
}
}
return vnode;
@@ -102,4 +102,11 @@ export default class Widget {
this.vnode = vnode;
return vnode;
}
private visitSubTree(callback: (w: Widget) => void) {
callback(this);
for (let child of this.children) {
child.visitSubTree(callback);
}
}
}