fix: properly destroy widget in some cases

when widget was (props)updated, then removed from DOM, it was not
destroyed.

closes #19
This commit is contained in:
Géry Debongnie
2019-04-09 15:24:15 +02:00
parent bc07c49a5f
commit 74ce6a671e
3 changed files with 47 additions and 4 deletions
+3 -1
View File
@@ -1019,7 +1019,9 @@ const widgetDirective: Directive = {
ctx.addLine(
`def${defID} = def${defID}.then(()=>{if (w${widgetID}.__widget__.isDestroyed) {return};let vnode;if (!w${widgetID}.__widget__.vnode){vnode=w${widgetID}.__widget__.pvnode} else { vnode=h(w${widgetID}.__widget__.vnode.sel, {key: ${templateID}});vnode.elm=w${widgetID}.el;vnode.data.hook = {insert(a){a.elm.parentNode.replaceChild(w${widgetID}.el,a.elm);a.elm=w${widgetID}.el;w${widgetID}.__mount();},remove(){w${widgetID}.${
keepAlive ? "unmount" : "destroy"
}()}}}c${ctx.parentNode}[_${dummyID}_index]=vnode;});`
}()}, destroy() {w${widgetID}.${keepAlive ? "unmount" : "destroy"}()}}}c${
ctx.parentNode
}[_${dummyID}_index]=vnode;});`
);
ctx.closeIf();