[IMP] qweb: log a warning if a t-foreach is used without t-key

closes #40
This commit is contained in:
Géry Debongnie
2019-04-16 17:49:33 +02:00
parent e19540fb04
commit b89327c831
4 changed files with 16 additions and 9 deletions
+7
View File
@@ -928,6 +928,13 @@ const forEachDirective: Directive = {
ctx.addLine(`context.${name} = _${keysID}[i];`);
ctx.addLine(`context.${name}_value = _${valuesID}[i];`);
const nodeCopy = <Element>node.cloneNode(true);
if (nodeCopy.tagName !== "t" && !nodeCopy.hasAttribute("t-key")) {
console.warn(
`Directive t-foreach should always be used with a t-key! (in template: '${
ctx.templateName
}')`
);
}
nodeCopy.removeAttribute("t-foreach");
qweb._compileNode(nodeCopy, ctx);
ctx.dedent();