mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] qweb, component: remove support for t-on on component node
This commit is contained in:
committed by
Aaron Bohy
parent
1296964ae2
commit
3eb63452e7
@@ -64,7 +64,6 @@ type LifecycleHook = Function;
|
||||
|
||||
export class ComponentNode<T extends typeof Component = any> implements VNode<ComponentNode> {
|
||||
el?: HTMLElement | Text | undefined;
|
||||
handlers: any = null;
|
||||
app: App;
|
||||
fiber: Fiber | null = null;
|
||||
component: InstanceType<T>;
|
||||
@@ -214,18 +213,6 @@ export class ComponentNode<T extends typeof Component = any> implements VNode<Co
|
||||
this.status = STATUS.MOUNTED;
|
||||
this.fiber!.appliedToDom = true;
|
||||
this.fiber = null;
|
||||
if (this.handlers) {
|
||||
for (let i = 0; i < this.handlers.length; i++) {
|
||||
const handler = this.handlers[i];
|
||||
const eventType = handler[0];
|
||||
const el = bdom.el!;
|
||||
el.addEventListener(eventType, (ev: Event) => {
|
||||
const info = this.handlers![i];
|
||||
const [, ctx, method] = info;
|
||||
(ctx.__owl__.component as any)[method](ev);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
moveBefore(other: ComponentNode | null, afterNode: Node | null) {
|
||||
|
||||
@@ -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
@@ -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 };
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user