mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
make sure env is propagated to child widgets
This commit is contained in:
@@ -49,7 +49,7 @@ export class Widget<T extends WEnv> {
|
|||||||
if (parent instanceof Widget) {
|
if (parent instanceof Widget) {
|
||||||
p = parent;
|
p = parent;
|
||||||
parent.__widget__.children.push(this);
|
parent.__widget__.children.push(this);
|
||||||
this.env = Object.create(parent.env);
|
this.env = parent.env;
|
||||||
} else {
|
} else {
|
||||||
this.env = parent;
|
this.env = parent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,11 @@ describe("basic widget properties", () => {
|
|||||||
await widget.mount(fixture);
|
await widget.mount(fixture);
|
||||||
expect(renderCalls).toBe(1);
|
expect(renderCalls).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("keep a reference to env", async () => {
|
||||||
|
const widget = new Widget(env);
|
||||||
|
expect(widget.env).toBe(env);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("lifecycle hooks", () => {
|
describe("lifecycle hooks", () => {
|
||||||
@@ -324,4 +329,11 @@ describe("composition", () => {
|
|||||||
(<any>widget.__widget__.children[0].__widget__.vnode).elm
|
(<any>widget.__widget__.children[0].__widget__.vnode).elm
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("parent env is propagated to child widgets", async () => {
|
||||||
|
const widget = new WidgetA(env);
|
||||||
|
await widget.mount(fixture);
|
||||||
|
|
||||||
|
expect(widget.__widget__.children[0].env).toBe(env);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user