[FIX] qweb: accept assignations in qweb expressions

closes #560
closes #569
This commit is contained in:
Géry Debongnie
2019-12-12 13:17:51 +01:00
committed by aab-odoo
parent b283e65ad4
commit 4e22dbcad6
5 changed files with 85 additions and 1 deletions
+18
View File
@@ -2026,6 +2026,24 @@ describe("other directives with t-component", () => {
expect(flag).toBe(true);
});
test("t-on with inline statement", async () => {
class Child extends Component<any, any> {
static template = xml`<span>child</span>`;
}
class Parent extends Component<any, any> {
static template = xml`<div><Child t-on-click="state.n = state.n + 1"/></div>`;
static components = { Child };
state = {n: 3};
}
const parent = new Parent();
await parent.mount(fixture);
expect(parent.state.n).toBe(3);
fixture.querySelector("span")!.click();
expect(parent.state.n).toBe(4);
});
test("t-on with handler bound to argument", async () => {
expect.assertions(3);
env.qweb.addTemplates(`