[IMP] t-on directive: allow empty handler

Closes #377
This commit is contained in:
Aaron Bohy
2019-10-25 10:58:18 +02:00
committed by Géry Debongnie
parent 0ea1091692
commit 2beb12678e
7 changed files with 131 additions and 14 deletions
+25
View File
@@ -2064,6 +2064,31 @@ describe("other directives with t-component", () => {
expect(fixture.innerHTML).toBe('<div>1<span></span></div>');
});
test("t-on with no handler (only modifiers)", async () => {
expect.assertions(2);
class ComponentB extends Component<any, any> {
static template = xml`<span></span>`;
}
class ComponentA extends Component<any, any> {
static template = xml`<p><ComponentB t-on-ev.prevent=""/></p>`;
static components = { ComponentB };
}
class Parent extends Component<any, any> {
static template = xml`<div><ComponentA t-on-ev="onEv"/></div>`;
static components = { ComponentA };
onEv(ev) {
expect(ev.defaultPrevented).toBe(true);
}
}
const parent = new Parent(env);
await parent.mount(fixture);
let componentB = children(children(parent)[0])[0];
componentB.trigger("ev");
expect(env.qweb.templates[Parent.template].fn.toString()).toMatchSnapshot();
});
test("t-if works with t-component", async () => {
env.qweb.addTemplate("ParentWidget", `<div><t t-component="child" t-if="state.flag"/></div>`);
class Child extends Widget {}