mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
wip
This commit is contained in:
@@ -20,11 +20,7 @@ function callPortal(
|
||||
target: string,
|
||||
content: (ctx: any, node: any, key: string) => BDom
|
||||
): BDom {
|
||||
const portal = new VPortal(target, content(ctx, parent, key)) as any;
|
||||
// make sure we cleanup only once
|
||||
if (!ctx.__owl)
|
||||
ctx.__owl__.willDestroy.push(() => portal.cleanup());
|
||||
ctx.__owl__.hasPortal = true;
|
||||
const portal = new VPortal(target, content(ctx, parent, key), ctx.__owl__) as any;
|
||||
return portal;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -7,13 +7,15 @@ export class VPortal extends VText implements Partial<VNode<VPortal>> {
|
||||
realBDom: BDom | null;
|
||||
target: HTMLElement | null = null;
|
||||
|
||||
constructor(selector: string, realBDom: BDom) {
|
||||
constructor(selector: string, realBDom: BDom, ownerComponent: ComponentNode) {
|
||||
super("");
|
||||
this.ownerComponent = ownerComponent;
|
||||
this.selector = selector;
|
||||
this.realBDom = realBDom;
|
||||
}
|
||||
mount(parent: HTMLElement, anchor: ChildNode) {
|
||||
super.mount(parent, anchor);
|
||||
this.ownerComponent.willDestroy.push(() => this.cleanup());
|
||||
this.target = document.querySelector(this.selector) as any;
|
||||
if (!this.target) {
|
||||
let el: any = this.el;
|
||||
|
||||
Reference in New Issue
Block a user