throw qweb error if invalid loop in t-foreach

This commit is contained in:
Géry Debongnie
2019-02-01 11:28:03 +01:00
parent d2d622b3c3
commit c46bad6e35
2 changed files with 11 additions and 0 deletions
+3
View File
@@ -644,6 +644,9 @@ const forEachDirective: Directive = {
const name = node.getAttribute("t-as")!;
let arrayID = ctx.generateID();
ctx.addLine(`let _${arrayID} = ${qweb._formatExpression(elems)};`);
ctx.addLine(
`if (!_${arrayID}) { throw new Error('QWeb error: Invalid loop expression')}`
);
ctx.addLine(
`if (typeof _${arrayID} === 'number') { _${arrayID} = Array.from(Array(_${arrayID}).keys())}`
);