mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] qweb: t-widget: accept dyn values
This commit is contained in:
committed by
Géry Debongnie
parent
26f14180e2
commit
376f801541
+32
-2
@@ -857,7 +857,7 @@ describe("composition", () => {
|
||||
const widget = new ParentWidget(env);
|
||||
await widget.mount(fixture);
|
||||
expect(fixture.innerHTML).toBe("<div><div>world</div></div>");
|
||||
delete QWeb.widgets['WidgetB'];
|
||||
delete QWeb.widgets["WidgetB"];
|
||||
});
|
||||
|
||||
test("don't fallback to global registry if widget defined locally", async () => {
|
||||
@@ -871,7 +871,7 @@ describe("composition", () => {
|
||||
const widget = new ParentWidget(env);
|
||||
await widget.mount(fixture);
|
||||
expect(fixture.innerHTML).toBe("<div><span>Belgium</span></div>");
|
||||
delete QWeb.widgets['WidgetB'];
|
||||
delete QWeb.widgets["WidgetB"];
|
||||
});
|
||||
|
||||
test("throw a nice error if it cannot find widget", async () => {
|
||||
@@ -1254,6 +1254,36 @@ describe("composition", () => {
|
||||
`)
|
||||
);
|
||||
});
|
||||
|
||||
test("t-widget with dynamic value", async () => {
|
||||
env.qweb.addTemplate(
|
||||
"ParentWidget",
|
||||
`<div><t t-widget="{{state.widget}}"/></div>`
|
||||
);
|
||||
class ParentWidget extends Widget {
|
||||
widgets = { WidgetB };
|
||||
state = { widget: "WidgetB" };
|
||||
}
|
||||
const widget = new ParentWidget(env);
|
||||
await widget.mount(fixture);
|
||||
expect(fixture.innerHTML).toBe("<div><div>world</div></div>");
|
||||
expect(env.qweb.templates.ParentWidget.fn.toString()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("t-widget with dynamic value 2", async () => {
|
||||
env.qweb.addTemplate(
|
||||
"ParentWidget",
|
||||
`<div><t t-widget="Widget{{state.widget}}"/></div>`
|
||||
);
|
||||
class ParentWidget extends Widget {
|
||||
widgets = { WidgetB };
|
||||
state = { widget: "B" };
|
||||
}
|
||||
const widget = new ParentWidget(env);
|
||||
await widget.mount(fixture);
|
||||
expect(fixture.innerHTML).toBe("<div><div>world</div></div>");
|
||||
expect(env.qweb.templates.ParentWidget.fn.toString()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe("props evaluation (with t-props directive)", () => {
|
||||
|
||||
Reference in New Issue
Block a user