mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] component: improve error message when invalid handler
This commit is contained in:
committed by
Aaron Bohy
parent
3fb65b3a89
commit
b33471e819
@@ -31,9 +31,13 @@ export const mainEventHandler = (data: any, ev: Event, currentTarget?: EventTarg
|
||||
// We check this rather than data[0] being truthy (or typeof function) so that it crashes
|
||||
// as expected when there is a handler expression that evaluates to a falsy value
|
||||
if (Object.hasOwnProperty.call(data, 0)) {
|
||||
const handler = data[0];
|
||||
if (typeof handler !== "function") {
|
||||
throw new Error(`Invalid handler (expected a function, received: '${handler}')`);
|
||||
}
|
||||
let node = data[1] ? data[1].__owl__ : null;
|
||||
if (node ? node.status === STATUS.MOUNTED : true) {
|
||||
data[0].call(node ? node.component : null, ev);
|
||||
handler.call(node ? node.component : null, ev);
|
||||
}
|
||||
}
|
||||
return stopped;
|
||||
|
||||
Reference in New Issue
Block a user