[FIX] compiler: t-key on a sub-domnode pushes an anchor in parent block

This commit is contained in:
Lucas Perais (lpe)
2022-01-20 16:26:05 +01:00
committed by Géry Debongnie
parent 45f6a8e97a
commit 055cbda750
3 changed files with 56 additions and 1 deletions
+20
View File
@@ -43,4 +43,24 @@ describe("t-key", () => {
})
).toBe("<ul><li>Chimay Rouge</li></ul>");
});
test("t-key on sub dom node pushes a child block in its parent", async () => {
const template = `
<div>
<t t-if="hasSpan"><span /></t>
<div t-key="key"><h1 /></div>
</div>
`;
expect(renderToString(template, { key: "1" })).toBe("<div><div><h1></h1></div></div>");
expect(renderToString(template, { hasSpan: true, key: "1" })).toBe(
"<div><span></span><div><h1></h1></div></div>"
);
const template2 = `
<div t-key="key"><h1 /></div>
`;
expect(renderToString(template2, { key: "1" })).toBe("<div><h1></h1></div>");
});
});