mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] t-call-context: fix capture making component available in ctx
Previously, when using a component with a slot within a t-call with t-call-context, the component would become available again inside the slot despite the t-call-context. This was caused by the fact that the capture helper function creates an object with the component as its prototype which is incorrect. It should just use the previous context as its prototype.
This commit is contained in:
committed by
Géry Debongnie
parent
39329f80b2
commit
3d40533de1
@@ -316,7 +316,7 @@ describe("t-call", () => {
|
||||
expect(fixture.innerHTML).toBe("childaaronchildlucas");
|
||||
});
|
||||
|
||||
test.only("t-call-context: ComponentNode is not looked up in the context", async () => {
|
||||
test("t-call-context: ComponentNode is not looked up in the context", async () => {
|
||||
let child: any;
|
||||
class Child extends Component {
|
||||
static template = xml`<t t-slot="default"/>`;
|
||||
@@ -357,4 +357,30 @@ describe("t-call", () => {
|
||||
expect(Object.keys(child.__owl__.refs)).toEqual([]);
|
||||
expect(Object.keys(root.__owl__.refs)).toEqual(["myRef", "myRef2"]);
|
||||
});
|
||||
|
||||
test("t-call-context: slots don't make component available again when context is captured", async () => {
|
||||
class Child extends Component {
|
||||
static template = xml`<t t-slot="default"/>`;
|
||||
}
|
||||
|
||||
class Root extends Component {
|
||||
static template = xml`<t t-call="template" t-call-context="{}"/>`;
|
||||
static components = { Child };
|
||||
someValue = "Hello";
|
||||
}
|
||||
|
||||
await mount(Root, fixture, {
|
||||
test: true,
|
||||
templates: `
|
||||
<templates>
|
||||
<t t-name="template">
|
||||
<t t-set="dummy" t-value="0"/>
|
||||
<Child>
|
||||
<t t-esc="someValue"/>
|
||||
</Child>
|
||||
</t>
|
||||
</templates>`,
|
||||
});
|
||||
expect(fixture.innerHTML).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user