[FIX] qweb, component: remove support for t-on on component node

This commit is contained in:
Lucas Perais (lpe)
2021-10-26 09:46:49 +02:00
committed by Aaron Bohy
parent 1296964ae2
commit 3eb63452e7
8 changed files with 29 additions and 355 deletions
-11
View File
@@ -968,17 +968,6 @@ export class QWebCompiler {
extraArgs.slots = slotDef;
}
// handlers
const hasHandlers = Object.keys(ast.handlers).length;
if (hasHandlers) {
const vars = Object.keys(ast.handlers).map((ev) => {
let id = this.generateId("h");
this.addLine(`let ${id} = ${this.generateHandlerCode(ast.handlers[ev], ev)};`);
return id;
});
extraArgs.handlers = `[${vars}]`;
}
if (block && ctx.forceNewBlock === false) {
// todo: check the forcenewblock condition
this.insertAnchor(block);
+4 -4
View File
@@ -107,7 +107,6 @@ export interface ASTComponent {
isDynamic: boolean;
dynamicProps: string | null;
props: { [name: string]: string };
handlers: { [event: string]: string };
slots: { [name: string]: AST };
}
@@ -667,11 +666,12 @@ function parseComponent(node: Element, ctx: ParsingContext): AST | null {
node.removeAttribute("t-props");
const props: ASTComponent["props"] = {};
const handlers: ASTComponent["handlers"] = {};
for (let name of node.getAttributeNames()) {
const value = node.getAttribute(name)!;
if (name.startsWith("t-on-")) {
handlers[name.slice(5)] = value;
throw new Error(
"t-on is no longer supported on Component node. Consider passing a callback in props."
);
} else {
props[name] = value;
}
@@ -715,7 +715,7 @@ function parseComponent(node: Element, ctx: ParsingContext): AST | null {
slots.default = defaultContent;
}
}
return { type: ASTType.TComponent, name, isDynamic, dynamicProps, props, handlers, slots };
return { type: ASTType.TComponent, name, isDynamic, dynamicProps, props, slots };
}
// -----------------------------------------------------------------------------