[FIX] component: bind t-ref widgets at correct moment

closes #51
This commit is contained in:
Géry Debongnie
2019-04-23 11:28:30 +02:00
parent 9170882010
commit 20b33f50fa
3 changed files with 28 additions and 7 deletions
+23
View File
@@ -657,6 +657,29 @@ describe("composition", () => {
expect(widget.refs.mywidgetb instanceof WidgetB).toBe(true);
});
test("t-refs are bound at proper timing", async () => {
expect.assertions(2);
class ParentWidget extends Widget {
inlineTemplate = `
<div>
<t t-foreach="state.list" t-ref="'child'" t-widget="Widget"/>
</div>`;
widgets = { Widget };
state = {list: <any>[]};
willPatch() {
expect(this.refs.child).toBeUndefined();
}
patched() {
expect(this.refs.child).not.toBeUndefined();
}
}
const parent = new ParentWidget(env);
await parent.mount(fixture);
parent.state.list.push(1);
await nextTick()
});
test("modifying a sub widget", async () => {
class ParentWidget extends Widget {
inlineTemplate = `<div><t t-widget="Counter"/></div>`;