mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] qweb: t-foreach needs to hold on scope
Have a t-on within a t-foreach the t-on has an expression Before this commit, when triggering the t-on, the expression was falsely evaluated In details, the expression took scope from outside the foreach loop as we protect it to have similar results than an actual for loop But, at triggering time, the scope protection had already been terminated meaning the info of the iteration of the loop the handler has been built in had already disappeared This commit fixes that closes #594
This commit is contained in:
committed by
Géry Debongnie
parent
21737d33fa
commit
21d1306ec2
@@ -58,7 +58,7 @@ export function makeHandlerCode(
|
||||
ctx.rootContext.shouldDefineUtils = true;
|
||||
const comp = `utils.getComponent(context)`;
|
||||
if (args) {
|
||||
let argId = ctx.generateID();
|
||||
const argId = ctx.generateID();
|
||||
ctx.addLine(`let args${argId} = [${ctx.formatExpression(args)}];`);
|
||||
code = `${comp}['${name}'](...args${argId}, e);`;
|
||||
putInCache = false;
|
||||
@@ -67,8 +67,9 @@ export function makeHandlerCode(
|
||||
}
|
||||
} else {
|
||||
// if we get here, then it is an expression
|
||||
// we need to capture every variable in it
|
||||
putInCache = false;
|
||||
code = ctx.formatExpression(value);
|
||||
code = ctx.captureExpression(value);
|
||||
}
|
||||
const modCode = mods.map(mod => modcodes[mod]).join("");
|
||||
let handler = `function (e) {if (!context.__owl__.isMounted){return}${modCode}${code}}`;
|
||||
|
||||
Reference in New Issue
Block a user