mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] qweb, t-call: t-call nested in t-slot
Have a t-call within a t-set-slot of a component.
The called template has a t-component directive.
It should be like:
```xml
<t t-name="Zero">
<Slotted>
<t t-call="someTemplate" />
</Slotted>
</t>
<t t-name="someTemplate">
<SomeComponent />
</t>
```
Before this commit, the parent of SomeComponent was the Zero component
After this commit, the parent of SomeComponent is the Slotted Component as it should be
closes #862
This commit is contained in:
committed by
Géry Debongnie
parent
9cbcf20b33
commit
d67d295eaa
@@ -1118,4 +1118,35 @@ describe("t-slot directive", () => {
|
||||
|
||||
expect(env.qweb.templates[Toggler.template].fn.toString()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("t-slot within dynamic t-call", async () => {
|
||||
let child;
|
||||
class Child extends Component {
|
||||
static template = xml`<div class="child"/>`;
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
child = this;
|
||||
}
|
||||
}
|
||||
|
||||
class Slotted extends Component {
|
||||
static template = xml`<div class="slotted"><t t-slot="default" /></div>`;
|
||||
}
|
||||
|
||||
class UsingTcallInSlotted extends Component {
|
||||
tcallTemplate = xml`<div class="slot"><Child/></div>`;
|
||||
static template = xml`
|
||||
<div>
|
||||
<Slotted>
|
||||
<t t-call="{{ tcallTemplate }}"/>
|
||||
</Slotted>
|
||||
</div>`;
|
||||
static components = { Slotted , Child };
|
||||
}
|
||||
|
||||
await mount(UsingTcallInSlotted, {target: fixture});
|
||||
|
||||
expect(child.__owl__.parent).toBeInstanceOf(Slotted);
|
||||
expect(fixture.innerHTML).toBe(`<div><div class="slotted"><div class="slot"><div class="child"></div></div></div></div>`);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user