[FIX] qweb: do not format expression twice in t-if

closes #392
This commit is contained in:
Géry Debongnie
2019-10-24 13:25:18 +02:00
committed by aab-odoo
parent a3317ab997
commit c2f42d3b82
3 changed files with 71 additions and 3 deletions
+2 -2
View File
@@ -133,7 +133,7 @@ QWeb.addDirective({
priority: 20,
atNodeEncounter({ node, ctx }): boolean {
let cond = ctx.getValue(node.getAttribute("t-if")!);
ctx.addIf(`${ctx.formatExpression(typeof cond === 'string' ? cond : cond.expr)}`);
ctx.addIf(typeof cond === 'string' ? ctx.formatExpression(cond) : cond.id);
return false;
},
finalize({ ctx }) {
@@ -146,7 +146,7 @@ QWeb.addDirective({
priority: 30,
atNodeEncounter({ node, ctx }): boolean {
let cond = ctx.getValue(node.getAttribute("t-elif")!);
ctx.addLine(`else if (${ctx.formatExpression(typeof cond === 'string' ? cond : cond.expr)}) {`);
ctx.addLine(`else if (${typeof cond === 'string' ? ctx.formatExpression(cond) : cond.id}) {`);
ctx.indent();
return false;
},