do not destroy and rerender sub widgets if not necessary

add failing test on rerendering sub widgets...
This commit is contained in:
Géry Debongnie
2019-01-27 22:16:00 +01:00
parent 9e0d1db8e4
commit 851d01b7ad
4 changed files with 60 additions and 14 deletions
+19
View File
@@ -516,6 +516,25 @@ describe("composition", () => {
expect(children(widget)[0].env).toBe(env);
});
test("rerendering a widget with a sub widget", async () => {
class ParentWidget extends Widget<WEnv> {
template = `<div><t t-widget="Counter"/></div>`;
widgets = { Counter };
}
const widget = new ParentWidget(env);
await widget.mount(fixture);
const button = fixture.getElementsByTagName("button")[0];
await button.click();
await nextTick();
expect(fixture.innerHTML).toBe(
"<div><div>1<button>Inc</button></div></div>"
);
await widget.render();
expect(fixture.innerHTML).toBe(
"<div><div>1<button>Inc</button></div></div>"
);
});
});
describe("props evaluation (with t-props directive)", () => {