fix context issue after loop t-foreach

This commit is contained in:
Géry Debongnie
2019-01-30 13:33:37 +01:00
parent 68973b3321
commit 4e4702c6cf
2 changed files with 23 additions and 1 deletions
+7 -1
View File
@@ -59,6 +59,12 @@ export class Context {
return newContext;
}
withInLoop(): Context {
const newContext = Object.create(this);
newContext.inLoop = true;
return newContext;
}
withCaller(node: Element): Context {
const newContext = Object.create(this);
newContext.caller = node;
@@ -629,7 +635,7 @@ const forEachDirective: Directive = {
priority: 10,
atNodeEncounter({ node, qweb, ctx }): boolean {
ctx.rootContext.shouldProtectContext = true;
ctx.inLoop = true;
ctx = ctx.withInLoop();
const elems = node.getAttribute("t-foreach")!;
const name = node.getAttribute("t-as")!;
let arrayID = ctx.generateID();