mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] compiler, components: allow empty slot
Before this commit, a t-set-slot that has no content was not even compiled, and thus not passed to the component for which it has was defined After this commit, we allow a t-set-slot to have no content (because it can have slot props)
This commit is contained in:
committed by
Géry Debongnie
parent
55dbc01a1b
commit
de240b1ebc
@@ -74,6 +74,43 @@ describe("slots", () => {
|
||||
expect(fixture.innerHTML).toBe("<span>other text</span>");
|
||||
});
|
||||
|
||||
test("simple named and empty slot", async () => {
|
||||
class Child extends Component {
|
||||
static template = xml`<span><t t-slot="default" /><t t-slot="myEmptySlot"/></span>`;
|
||||
|
||||
setup() {
|
||||
expect(this.props.slots["myEmptySlot"]).toBeTruthy();
|
||||
}
|
||||
}
|
||||
|
||||
class Parent extends Component {
|
||||
static template = xml`<Child>some text<t t-set-slot="myEmptySlot" /></Child>`;
|
||||
static components = { Child };
|
||||
}
|
||||
await mount(Parent, fixture);
|
||||
|
||||
expect(fixture.innerHTML).toBe("<span>some text</span>");
|
||||
});
|
||||
|
||||
test("simple named and empty slot -- 2", async () => {
|
||||
class Child extends Component {
|
||||
static template = xml`<span><t t-slot="myEmptySlot">default empty</t></span>`;
|
||||
|
||||
setup() {
|
||||
expect(this.props.slots["myEmptySlot"]).toBeTruthy();
|
||||
expect(this.props.slots["myEmptySlot"].myProp).toBe("myProp text");
|
||||
}
|
||||
}
|
||||
|
||||
class Parent extends Component {
|
||||
static template = xml`<Child><t t-set-slot="myEmptySlot" myProp="'myProp text'" /></Child>`;
|
||||
static components = { Child };
|
||||
}
|
||||
await mount(Parent, fixture);
|
||||
|
||||
expect(fixture.innerHTML).toBe("<span>default empty</span>");
|
||||
});
|
||||
|
||||
test("default slot with slot scope: shorthand syntax", async () => {
|
||||
let child: any;
|
||||
class Child extends Component {
|
||||
|
||||
Reference in New Issue
Block a user