fix issue with mounted widget without proper vnode

This commit is contained in:
Géry Debongnie
2019-01-25 15:44:32 +01:00
parent 6f6e2d887d
commit 37b275d40e
3 changed files with 37 additions and 21 deletions
+3 -2
View File
@@ -133,8 +133,9 @@ export class Widget<T extends WEnv> {
return Promise.all(promises).then(() => vnode);
}
_mount(el: HTMLElement) {
this.el = el;
_mount(vnode: VNode) {
this.el = <HTMLElement>vnode.elm;
this._.vnode = vnode;
if (this._.parent) {
if (this._.parent._.isMounted) {
this._.isMounted = true;
+1 -1
View File
@@ -685,7 +685,7 @@ const widgetDirective: Directive = {
`let _${widgetID} = new context.widgets['${value}'](context, ${props})`
);
ctx.addLine(
`let def${defID} = _${widgetID}._start().then(() => _${widgetID}._render()).then(vnode=>{Object.assign(_${dummyID}, vnode);_${dummyID}.key="${dummyID}";_${dummyID}.data.hook = {create(_,vn){_${widgetID}._mount(vn.elm)}}})`
`let def${defID} = _${widgetID}._start().then(() => _${widgetID}._render()).then(vnode=>{Object.assign(_${dummyID}, vnode);_${dummyID}.key="${dummyID}";_${dummyID}.data.hook = {create(_,vn){_${widgetID}._mount(vn)}}})`
);
ctx.addLine(`extra.promises.push(def${defID})`);