mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] qweb: t-key in t-foreach is mandatory, throws otherwise
This commit is contained in:
committed by
Aaron Bohy
parent
c71db28bc6
commit
1296964ae2
@@ -742,11 +742,6 @@ export class QWebCompiler {
|
||||
|
||||
const subCtx: Context = createContext(ctx, { block, index: loopVar });
|
||||
this.compileAST(ast.body, subCtx);
|
||||
if (!ast.key) {
|
||||
console.warn(
|
||||
`"Directive t-foreach should always be used with a t-key! (in template: '${this.templateName}')"`
|
||||
);
|
||||
}
|
||||
if (ast.memo) {
|
||||
this.addLine(
|
||||
`nextCache[key${this.target.loopLevel}] = assign(${c}[${loopVar}], {memo: memo${id!}});`
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user