mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: better templateId for multiple subcomponents
Of course, the templateId computation is kind of tricky. Here, an issue occurred because the templateId did not take the componentId into account when we were in a loop, but with no keyed parent. This meant that multiple sub components shared the same templateId, confusing the vdom algorithm.
This commit is contained in:
@@ -1373,6 +1373,33 @@ describe("composition", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("list of two sub components inside other nodes", async () => {
|
||||
// this confuses the patching algorithm...
|
||||
env.qweb.addTemplate("ChildWidget", `<span>child</span>`);
|
||||
|
||||
env.qweb.addTemplates(`
|
||||
<templates>
|
||||
<div t-name="Parent">
|
||||
<div t-foreach="state.blips" t-as="blip" t-key="blip.id">
|
||||
<SubWidget />
|
||||
<SubWidget />
|
||||
</div>
|
||||
</div>
|
||||
<span t-name="SubWidget">asdf</span>
|
||||
</templates>`);
|
||||
|
||||
class SubWidget extends Widget {}
|
||||
class Parent extends Widget {
|
||||
components = { SubWidget };
|
||||
state = { blips: [{ a: "a", id: 1 }] };
|
||||
}
|
||||
const parent = new Parent(env);
|
||||
await parent.mount(fixture);
|
||||
expect(fixture.innerHTML).toBe(
|
||||
"<div><div><span>asdf</span><span>asdf</span></div></div>"
|
||||
);
|
||||
});
|
||||
|
||||
test("t-component with dynamic value", async () => {
|
||||
env.qweb.addTemplate("ParentWidget", `<div><t t-component="{{state.widget}}"/></div>`);
|
||||
class ParentWidget extends Widget {
|
||||
|
||||
Reference in New Issue
Block a user