mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user