mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
implement destroy, add tests
This commit is contained in:
+12
-8
@@ -25,7 +25,9 @@ export default class Widget {
|
||||
this.parent = parent;
|
||||
if (parent) {
|
||||
parent.children.push(this);
|
||||
this.setEnvironment(parent.env);
|
||||
if (parent.env) {
|
||||
this.setEnvironment(parent.env);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,16 +48,18 @@ export default class Widget {
|
||||
target.appendChild(this.el!);
|
||||
}
|
||||
|
||||
destroy() {}
|
||||
|
||||
setEnvironment(env: Env | null) {
|
||||
this.env = env ? Object.create(env) : null;
|
||||
if (this.env) {
|
||||
this.env.qweb.addTemplate(this.name, this.template);
|
||||
delete this.template;
|
||||
destroy() {
|
||||
if (this.el) {
|
||||
this.el.remove();
|
||||
}
|
||||
}
|
||||
|
||||
setEnvironment(env: Env) {
|
||||
this.env = Object.create(env);
|
||||
env.qweb.addTemplate(this.name, this.template);
|
||||
delete this.template;
|
||||
}
|
||||
|
||||
async updateState(newState: Object) {
|
||||
Object.assign(this.state, newState);
|
||||
await this.render();
|
||||
|
||||
Reference in New Issue
Block a user