[FIX] qweb/component: fix scoping issue with list of widgets

In a t-foreach loop, there was a bad interaction between variables
defined with the `var` keyword and asynchronous code.

closes #108
This commit is contained in:
Géry Debongnie
2019-05-15 15:18:27 +02:00
parent 9556696fa8
commit 9c1d369e94
4 changed files with 161 additions and 132 deletions
+29
View File
@@ -1823,6 +1823,35 @@ describe("async rendering", () => {
);
});
test("widgets in a node in a t-foreach ", async () => {
class Child extends Widget {}
class App extends Widget {
widgets = { Child };
get items() {
return [1, 2];
}
}
env.qweb.addTemplates(`
<templates>
<div t-name="Child"><t t-esc="props.item"/></div>
<div t-name="App">
<ul>
<t t-foreach="items" t-as="item">
<li t-key="'li_'+item">
<t t-widget="Child" t-props="{ item }"/>
</li>
</t>
</ul>
</div>
</templates>`);
const app = new App(env);
await app.mount(fixture);
expect(fixture.innerHTML).toBe("<div><ul><li><div>1</div></li><li><div>2</div></li></ul></div>");
});
test("properly behave when destroyed/unmounted while rendering ", async () => {
let def = Promise.resolve();