[FIX] component: properly handle wrapper component and slots

closes #297
This commit is contained in:
Géry Debongnie
2019-09-22 22:24:24 +02:00
parent 78a4550ebb
commit 82a6961b3a
5 changed files with 124 additions and 105 deletions
+25 -6
View File
@@ -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", () => {