diff --git a/web/static/src/ts/core/qweb_vdom.ts b/web/static/src/ts/core/qweb_vdom.ts index af1eda93..a591f309 100644 --- a/web/static/src/ts/core/qweb_vdom.ts +++ b/web/static/src/ts/core/qweb_vdom.ts @@ -381,7 +381,7 @@ export class QWeb { // dynamic attributes if (name.startsWith("t-att-")) { const attName = name.slice(6); - const formattedValue = this._formatExpression(value!); + const formattedValue = this._formatExpression(ctx.getValue(value!)); const attID = ctx.generateID(); ctx.addLine(`let _${attID} = ${formattedValue};`); attrs.push(`${attName}: _${attID}`); diff --git a/web/static/tests/core/__snapshots__/qweb_vdom.test.ts.snap b/web/static/tests/core/__snapshots__/qweb_vdom.test.ts.snap index ea201244..9dd17fbb 100644 --- a/web/static/tests/core/__snapshots__/qweb_vdom.test.ts.snap +++ b/web/static/tests/core/__snapshots__/qweb_vdom.test.ts.snap @@ -77,6 +77,20 @@ exports[`attributes format value 1`] = ` }" `; +exports[`attributes from variables set previously 1`] = ` +"function anonymous(context,extra +) { + let h = this.h; + let c1 = [], p1 = {}; + let vn1 = h('div', p1, c1); + let _2 = 'def'; + let c3 = [], p3 = {attrs:{class: _2}}; + let vn3 = h('span', p3, c3); + c1.push(vn3); + return vn1; +}" +`; + exports[`attributes object 1`] = ` "function anonymous(context,extra ) { diff --git a/web/static/tests/core/qweb_vdom.test.ts b/web/static/tests/core/qweb_vdom.test.ts index 1982a8a5..e20dac5f 100644 --- a/web/static/tests/core/qweb_vdom.test.ts +++ b/web/static/tests/core/qweb_vdom.test.ts @@ -353,6 +353,28 @@ describe("attributes", () => { expect(result).toBe(`
`); }); + test("from variables set previously", () => { + qweb.addTemplate( + "test", + `