mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] app: mount app in "first-child" position
We reintroduce the possibility to mount the app in first position in a target. The option "self" has been dropped since it is now possible for a component to have several top level nodes.
This commit is contained in:
committed by
Aaron Bohy
parent
aa3148eddf
commit
ebd2e4324f
+15
-2
@@ -158,17 +158,30 @@ export class RootFiber extends Fiber {
|
||||
|
||||
export let __internal__destroyed: ComponentNode[] = [];
|
||||
|
||||
type Position = "first-child" | "last-child";
|
||||
|
||||
export interface MountOptions {
|
||||
position?: Position;
|
||||
}
|
||||
|
||||
export class MountFiber extends RootFiber {
|
||||
target: HTMLElement;
|
||||
position: Position;
|
||||
|
||||
constructor(node: ComponentNode, target: HTMLElement) {
|
||||
constructor(node: ComponentNode, target: HTMLElement, options: MountOptions = {}) {
|
||||
super(node);
|
||||
this.target = target;
|
||||
this.position = options.position || "last-child";
|
||||
}
|
||||
complete() {
|
||||
const node = this.node;
|
||||
node.bdom = this.bdom;
|
||||
mount(node.bdom!, this.target);
|
||||
if (this.position === "last-child" || this.target.childNodes.length === 0) {
|
||||
mount(node.bdom!, this.target);
|
||||
} else {
|
||||
const firstChild = this.target.childNodes[0];
|
||||
mount(node.bdom!, this.target, firstChild);
|
||||
}
|
||||
node.status = STATUS.MOUNTED;
|
||||
this.appliedToDom = true;
|
||||
let current;
|
||||
|
||||
Reference in New Issue
Block a user