add t-ref directive

This commit is contained in:
Géry Debongnie
2019-01-21 15:46:29 +01:00
parent 64557ae999
commit 9be5cc1760
6 changed files with 53 additions and 15 deletions
+12 -1
View File
@@ -69,7 +69,7 @@ describe("error handling", () => {
test("template with text node and tag", () => {
const qweb = new QWeb();
qweb.addTemplate("test", `<t t-debug="1">text<span>other node</span></t>`);
qweb.addTemplate("test", `<t>text<span>other node</span></t>`);
expect(() => renderToString(qweb, "test")).toThrow(
"A template should not have more than one root node"
@@ -652,3 +652,14 @@ describe("t-on", () => {
expect(a).toBe(6);
});
});
describe("t-ref", () => {
test("can get a ref on a node", () => {
const qweb = new QWeb();
qweb.addTemplate("test", `<div><span t-ref="myspan"/></div>`);
let refs: any = {};
renderToDOM(qweb, "test", { refs});
expect(refs.myspan.tagName).toBe('SPAN');
});
});