[FIX] component: capture ref key in closure

This is what commit d3197e9865 should have
done. Many changes should be done on normal nodes and on components!

closes #77
This commit is contained in:
Géry Debongnie
2019-05-04 22:46:58 +02:00
parent 7c8fc323e1
commit eb508b7660
2 changed files with 27 additions and 11 deletions
+15
View File
@@ -901,6 +901,21 @@ describe("composition", () => {
);
});
test("refs in a loop", async () => {
class ParentWidget extends Widget {
inlineTemplate = `<div>
<t t-foreach="state.items" t-as="item">
<t t-widget="Child" t-ref="item" t-key="item"/>
</t>
</div>`;
state = { items: [1, 2, 3] };
widgets = { Child: Widget };
}
const parent = new ParentWidget(env);
await parent.mount(fixture);
expect(Object.keys(parent.refs)).toEqual(["1", "2", "3"]);
});
test("parent's elm for a children === children's elm, even after rerender", async () => {
const widget = new WidgetA(env);
await widget.mount(fixture);