mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[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:
@@ -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>&lt;ok&gt;abc&lt;/ok&gt;</span>");
|
||||
expect(renderToString(qweb, "test", { var: "<ok>abc</ok>" })).toBe(
|
||||
"<span>&lt;ok&gt;abc&lt;/ok&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;
|
||||
|
||||
Reference in New Issue
Block a user