mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component: properly handle wrapper component and slots
closes #297
This commit is contained in:
@@ -2312,16 +2312,16 @@ describe("random stuff/miscellaneous", () => {
|
||||
});
|
||||
|
||||
test("can inject values in tagged templates", async () => {
|
||||
const SUBTEMPLATE = xml`<span><t t-esc="state.n"/></span>`
|
||||
class Parent extends Widget {
|
||||
static template = xml`<div><t t-call="${SUBTEMPLATE}"/></div>`
|
||||
state = {n: 42};
|
||||
}
|
||||
const SUBTEMPLATE = xml`<span><t t-esc="state.n"/></span>`;
|
||||
class Parent extends Widget {
|
||||
static template = xml`<div><t t-call="${SUBTEMPLATE}"/></div>`;
|
||||
state = { n: 42 };
|
||||
}
|
||||
|
||||
const widget = new Parent(env);
|
||||
await widget.mount(fixture);
|
||||
expect(env.qweb.templates[Parent.template].fn.toString()).toMatchSnapshot();
|
||||
expect(fixture.innerHTML).toBe('<div><span>42</span></div>')
|
||||
expect(fixture.innerHTML).toBe("<div><span>42</span></div>");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3476,6 +3476,25 @@ describe("t-slot directive", () => {
|
||||
await nextTick();
|
||||
expect(fixture.innerHTML).toBe("<div><button>Inc[5]</button><div><div> SC:5</div></div></div>");
|
||||
});
|
||||
|
||||
test("slots and wrapper components", async () => {
|
||||
class Link extends Component<any, any, any> {
|
||||
static template = xml`
|
||||
<a href="abc">
|
||||
<t t-slot="default"/>
|
||||
</a>`;
|
||||
}
|
||||
|
||||
class A extends Component<any, any, any> {
|
||||
static template = xml`<Link>hey</Link>`;
|
||||
static components = { Link: Link };
|
||||
}
|
||||
|
||||
const a = new A(env);
|
||||
await a.mount(fixture);
|
||||
|
||||
expect(fixture.innerHTML).toBe(`<a href="abc">hey</a>`);
|
||||
});
|
||||
});
|
||||
|
||||
describe("t-model directive", () => {
|
||||
|
||||
Reference in New Issue
Block a user