mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: multiple t-calls
Before this commit, owl could crash in some specific situations: multiple t-calls with sub components, outside a loop. The reason is that the t-call did not generate a key, so from the point of view of the children component, it had the same key, even though it was at a different place in a template. Also, with this fix, we can fix the playground responsive example. closes #602
This commit is contained in:
@@ -5726,4 +5726,30 @@ describe("t-call", () => {
|
||||
|
||||
fixture.querySelector("p")!.click();
|
||||
});
|
||||
|
||||
test("sub components in two t-calls", async () => {
|
||||
class Child extends Component<any,any> {
|
||||
static template = xml`<span><t t-esc="props.val"/></span>`;
|
||||
}
|
||||
|
||||
env.qweb.addTemplate("sub", `<Child val="state.val"/>`);
|
||||
class Parent extends Component<any, any> {
|
||||
static template = xml`
|
||||
<div>
|
||||
<t t-if="state.val===1">
|
||||
<t t-call="sub"/>
|
||||
</t>
|
||||
<div t-else=""><t t-call="sub"/></div>
|
||||
</div>`;
|
||||
static components = { Child };
|
||||
state = useState({val: 1});
|
||||
}
|
||||
const parent = new Parent();
|
||||
await parent.mount(fixture);
|
||||
expect(fixture.innerHTML).toBe("<div><span>1</span></div>");
|
||||
parent.state.val = 2;
|
||||
await nextTick();
|
||||
expect(fixture.innerHTML).toBe("<div><div><span>2</span></div></div>");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user