diff --git a/web/static/src/ts/core/qweb_vdom.ts b/web/static/src/ts/core/qweb_vdom.ts index 7e4ab194..d2563d96 100644 --- a/web/static/src/ts/core/qweb_vdom.ts +++ b/web/static/src/ts/core/qweb_vdom.ts @@ -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(); diff --git a/web/static/tests/core/widget.test.ts b/web/static/tests/core/widget.test.ts index ce7710bc..0a54d132 100644 --- a/web/static/tests/core/widget.test.ts +++ b/web/static/tests/core/widget.test.ts @@ -698,3 +698,19 @@ describe("props evaluation (with t-props directive)", () => { expect(fixture.innerHTML).toBe("