[FIX] qweb: t-key in t-foreach is mandatory, throws otherwise

This commit is contained in:
Lucas Perais (lpe)
2021-10-26 09:48:31 +02:00
committed by Géry Debongnie
parent b25f476c22
commit dd4848f602
8 changed files with 156 additions and 121 deletions
+5
View File
@@ -415,6 +415,11 @@ function parseTForEach(node: Element, ctx: ParsingContext): AST | null {
const elem = node.getAttribute("t-as") || "";
node.removeAttribute("t-as");
const key = node.getAttribute("t-key");
if (!key) {
throw new Error(
`"Directive t-foreach should always be used with a t-key!" (expression: t-foreach="${collection}" t-as="${elem}")`
);
}
node.removeAttribute("t-key");
const memo = node.getAttribute("t-memo") || "";
node.removeAttribute("t-memo");