[FIX] compiler: slot are called with a specific and different key

This commit is contained in:
Lucas Perais (lpe)
2022-01-14 15:29:00 +01:00
committed by Aaron Bohy
parent 6a7703ea82
commit cec451fd15
3 changed files with 133 additions and 0 deletions
+45
View File
@@ -1544,4 +1544,49 @@ describe("slots", () => {
}
await mount(Parent, fixture);
});
test("slot content has different key from other content -- static slot", async () => {
class Child extends Component {
static template = xml`<div t-esc="props.parent" />`;
}
class SlotDisplay extends Component {
static components = { Child };
static template = xml`<Child parent="'SlotDisplay'" /><t t-slot="default" />`;
}
class Parent extends Component {
static components = { Child, SlotDisplay };
static template = xml`
<SlotDisplay>
<Child parent="'Parent'" />
</SlotDisplay>`;
}
await mount(Parent, fixture);
expect(fixture.innerHTML).toBe("<div>SlotDisplay</div><div>Parent</div>");
});
test("slot content has different key from other content -- dynamic slot", async () => {
class Child extends Component {
static template = xml`<div t-esc="props.parent" />`;
}
class SlotDisplay extends Component {
static components = { Child };
slotName = "default";
static template = xml`<Child parent="'SlotDisplay'" /><t t-slot="{{ slotName }}" />`;
}
class Parent extends Component {
static components = { Child, SlotDisplay };
static template = xml`
<SlotDisplay>
<Child parent="'Parent'" />
</SlotDisplay>`;
}
await mount(Parent, fixture);
expect(fixture.innerHTML).toBe("<div>SlotDisplay</div><div>Parent</div>");
});
});