refactoring, work on environment

This commit is contained in:
Géry Debongnie
2019-01-23 14:28:41 +01:00
parent 08938d2334
commit 76fedae5a9
18 changed files with 138 additions and 63 deletions
+15
View File
@@ -651,6 +651,21 @@ describe("t-on", () => {
(<HTMLElement>node).click();
expect(a).toBe(6);
});
test("can bind handlers with loop variable as argument", () => {
expect.assertions(1);
const qweb = new QWeb();
qweb.addTemplate("test", `
<ul>
<li t-foreach="['someval']" t-as="action"><a t-on-click="activate(action)">link</a></li>
</ul>`);
const node = renderToDOM(qweb, "test", {
activate(action) {
expect(action).toBe('someval');
}
});
(<HTMLElement>node).getElementsByTagName('a')[0].click();
});
});
+6 -3
View File
@@ -1,9 +1,12 @@
import Widget, {WidgetEnv} from "../src/ts/core/widget";
import Widget, {WEnv} from "../src/ts/core/widget";
import QWeb from "../src/ts/core/qweb_vdom";
import { Type } from "../src/ts/types";
type TestEnv = WidgetEnv;
interface Type<T> extends Function {
new (...args: any[]): T;
}
type TestEnv = WEnv;
type TestWidget = Widget<TestEnv>
function makeWidget(W: Type<TestWidget>): TestWidget {