mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
fix issue with event binding in some cases
This commit is contained in:
@@ -725,12 +725,18 @@ const onDirective: Directive = {
|
||||
extraArgs = args.slice(1, -1);
|
||||
return "";
|
||||
});
|
||||
ctx.addLine(
|
||||
`extra.handlers[${nodeID}] = extra.handlers[${nodeID}] || context['${handler}'].bind(owner${
|
||||
extraArgs ? ", " + qweb._formatExpression(extraArgs) : ""
|
||||
});`
|
||||
);
|
||||
ctx.addLine(`p${nodeID}.on = {${eventName}: extra.handlers[${nodeID}]};`);
|
||||
if (extraArgs) {
|
||||
ctx.addLine(
|
||||
`p${nodeID}.on = {${eventName}: context['${handler}'].bind(owner, ${qweb._formatExpression(
|
||||
extraArgs
|
||||
)})};`
|
||||
);
|
||||
} else {
|
||||
ctx.addLine(
|
||||
`extra.handlers[${nodeID}] = extra.handlers[${nodeID}] || context['${handler}'].bind(owner);`
|
||||
);
|
||||
ctx.addLine(`p${nodeID}.on = {${eventName}: extra.handlers[${nodeID}]};`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -904,8 +904,7 @@ exports[`t-on can bind handlers with arguments 1`] = `
|
||||
let h = this.h;
|
||||
let c1 = [], p1 = {};
|
||||
let vn1 = h('button', p1, c1);
|
||||
extra.handlers[1] = extra.handlers[1] || context['add'].bind(owner, 5);
|
||||
p1.on = {click: extra.handlers[1]};
|
||||
p1.on = {click: context['add'].bind(owner, 5)};
|
||||
c1.push({text: \`Click\`});
|
||||
return vn1;
|
||||
}"
|
||||
@@ -939,8 +938,7 @@ exports[`t-on can bind handlers with loop variable as argument 1`] = `
|
||||
let c6 = [], p6 = {};
|
||||
let vn6 = h('a', p6, c6);
|
||||
c5.push(vn6);
|
||||
extra.handlers[6] = extra.handlers[6] || context['activate'].bind(owner, context['action']);
|
||||
p6.on = {click: extra.handlers[6]};
|
||||
p6.on = {click: context['activate'].bind(owner, context['action'])};
|
||||
c6.push({text: \`link\`});
|
||||
}
|
||||
c1.push({text: \`
|
||||
|
||||
Reference in New Issue
Block a user