[REF] qweb: improve t-on generated code

and deduplicate logic between directive t-on applied on a node and on a
component
This commit is contained in:
Géry Debongnie
2019-12-12 12:18:08 +01:00
committed by aab-odoo
parent f517d44e32
commit b283e65ad4
10 changed files with 176 additions and 180 deletions
+8 -5
View File
@@ -122,7 +122,9 @@ describe("t-esc", () => {
test("escaping", () => {
qweb.addTemplate("test", `<span><t t-esc="var"/></span>`);
expect(renderToString(qweb, "test", { var: "<ok>abc</ok>" })).toBe("<span>&amp;lt;ok&amp;gt;abc&amp;lt;/ok&amp;gt;</span>");
expect(renderToString(qweb, "test", { var: "<ok>abc</ok>" })).toBe(
"<span>&amp;lt;ok&amp;gt;abc&amp;lt;/ok&amp;gt;</span>"
);
});
test("escaping on a node", () => {
@@ -636,7 +638,7 @@ describe("attributes", () => {
baz: 1,
qux: { qux: "<>" }
});
const expected = "<div foo=\"<foo\" bar=\"0\" baz=\"<1>\" qux=\"<>\"></div>";
const expected = '<div foo="<foo" bar="0" baz="<1>" qux="<>"></div>';
expect(result).toBe(expected);
});
@@ -883,9 +885,10 @@ describe("t-call (template calling", () => {
});
test("t-call, conditional and t-set in t-call body", () => {
QWeb.registerTemplate("callee1", '<div>callee1</div>');
QWeb.registerTemplate("callee1", "<div>callee1</div>");
QWeb.registerTemplate("callee2", '<div>callee2 <t t-esc="v"/></div>');
QWeb.registerTemplate("caller",
QWeb.registerTemplate(
"caller",
`<div>
<t t-set="v1" t-value="'elif'"/>
<t t-if="v1 === 'if'" t-call="callee1" />
@@ -1117,7 +1120,7 @@ describe("misc", () => {
});
});
describe("t-on", () => {
describe.only("t-on", () => {
test("can bind event handler", () => {
qweb.addTemplate("test", `<button t-on-click="add">Click</button>`);
let a = 1;