[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
+18
View File
@@ -1213,6 +1213,24 @@ describe("t-on", () => {
expect(steps).toEqual([1, 2]);
});
test("t-on with empty handler (only modifiers)", () => {
expect.assertions(2);
qweb.addTemplate(
"test",
`<div>
<button t-on-click.prevent="">Button</button>
</div>`
);
const node = renderToDOM(qweb, "test", {}, { handlers: [] });
node.addEventListener('click', (e) => {
expect(e.defaultPrevented).toBe(true);
});
const button = (<HTMLElement>node).getElementsByTagName("button")[0];
button.click();
});
test("t-on combined with t-esc", async () => {
expect.assertions(3);
qweb.addTemplate("test", `<div><button t-on-click="onClick" t-esc="text"/></div>`);