diff --git a/src/qweb.ts b/src/qweb.ts index 15ecd4e0..27789b50 100644 --- a/src/qweb.ts +++ b/src/qweb.ts @@ -511,7 +511,7 @@ export class QWeb { } } - _formatExpression(e: string): string { + _formatExpression(e: string, ctx?: Context): string { if (e in this.exprCache) { return this.exprCache[e]; } @@ -537,7 +537,10 @@ export class QWeb { } else if (c.match(/\W/) && invar.length) { // TODO: Should check for possible spaces before dot if (chars[invarPos - 1] !== "." && RESERVED_WORDS.indexOf(invar) < 0) { - invar = WORD_REPLACEMENT[invar] || "context['" + invar + "']"; + invar = + WORD_REPLACEMENT[invar] || + (ctx && invar in ctx.variables && ctx.variables[invar]) || + "context['" + invar + "']"; } r += invar; invar = ""; @@ -847,7 +850,7 @@ const widgetDirective: Directive = { if (!val) { val = key; } - return `${key}: ${qweb._formatExpression(val)}`; + return `${key}: ${qweb._formatExpression(val, ctx)}`; }) .join(","); props = "{" + innerProp + "}"; diff --git a/tests/component.test.ts b/tests/component.test.ts index 6325f878..4beb011c 100644 --- a/tests/component.test.ts +++ b/tests/component.test.ts @@ -787,6 +787,27 @@ describe("props evaluation (with t-props directive)", () => { await widget.mount(fixture); expect(fixture.innerHTML).toBe("
hello aaron
"); }); + + test("t-set works with t-props", async () => { + class Parent extends Widget { + inlineTemplate = ` +
+ + +
`; + widgets = { child: Child } + } + class Child extends Widget { + inlineTemplate = ` + + + `; + } + + const widget = new Parent(env); + await widget.mount(fixture); + expect(normalize(fixture.innerHTML)).toBe("
42
"); + }); }); describe("other directives with t-widget", () => {