mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
add router service, better structure for demo app
This commit is contained in:
+9
-13
@@ -18,9 +18,9 @@ export default class Widget {
|
||||
template: string = "<div></div>";
|
||||
vnode: VNode | null = null;
|
||||
|
||||
parent: Widget | null;
|
||||
parent: Widget | null = null;
|
||||
children: Widget[] = [];
|
||||
env: Env | null = null;
|
||||
env: Env;
|
||||
el: HTMLElement | null = null;
|
||||
state: Object = {};
|
||||
refs: { [key: string]: Widget } = {};
|
||||
@@ -29,13 +29,13 @@ export default class Widget {
|
||||
// Lifecycle
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
constructor(parent: Widget | null, props?: any) {
|
||||
this.parent = parent;
|
||||
if (parent) {
|
||||
constructor(parent: Widget | Env, props?: any) {
|
||||
if (parent instanceof Widget) {
|
||||
this.parent = parent;
|
||||
parent.children.push(this);
|
||||
if (parent.env) {
|
||||
this.setEnvironment(parent.env);
|
||||
}
|
||||
this.env = Object.create(parent.env);
|
||||
} else {
|
||||
this.env = parent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ export default class Widget {
|
||||
if (target) {
|
||||
target.appendChild(this.el!);
|
||||
if (document.body.contains(target)) {
|
||||
this.visitSubTree(w => w.mounted())
|
||||
this.visitSubTree(w => w.mounted());
|
||||
}
|
||||
}
|
||||
return vnode;
|
||||
@@ -71,10 +71,6 @@ export default class Widget {
|
||||
}
|
||||
}
|
||||
|
||||
setEnvironment(env: Env) {
|
||||
this.env = Object.create(env);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOCSTRIGN
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user