[IMP] portal: ensure that destroy is synchronous

This commit is contained in:
Géry Debongnie
2022-01-19 13:53:07 +01:00
committed by Aaron Bohy
parent 5a2c769eab
commit eab0caa6cb
3 changed files with 74 additions and 7 deletions
+8 -7
View File
@@ -35,9 +35,11 @@ class VPortal extends VText implements Partial<VNode<VPortal>> {
this.realBDom!.beforeRemove();
}
remove() {
super.remove();
this.realBDom!.remove();
this.realBDom = null;
if (this.realBDom) {
super.remove();
this.realBDom!.remove();
this.realBDom = null;
}
}
patch(other: VPortal) {
@@ -64,10 +66,9 @@ export class Portal extends Component {
const node = this.__owl__;
const renderFn = node.renderFn;
node.renderFn = () => new VPortal(this.props.target, renderFn());
onWillUnmount(async () => {
await Promise.resolve();
if (node.bdom && (node.bdom as any).realBDom) {
(node.bdom as any).realBDom.remove();
onWillUnmount(() => {
if (node.bdom) {
node.bdom.remove();
}
});
}