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,13 +725,19 @@ const onDirective: Directive = {
|
|||||||
extraArgs = args.slice(1, -1);
|
extraArgs = args.slice(1, -1);
|
||||||
return "";
|
return "";
|
||||||
});
|
});
|
||||||
|
if (extraArgs) {
|
||||||
ctx.addLine(
|
ctx.addLine(
|
||||||
`extra.handlers[${nodeID}] = extra.handlers[${nodeID}] || context['${handler}'].bind(owner${
|
`p${nodeID}.on = {${eventName}: context['${handler}'].bind(owner, ${qweb._formatExpression(
|
||||||
extraArgs ? ", " + qweb._formatExpression(extraArgs) : ""
|
extraArgs
|
||||||
});`
|
)})};`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ctx.addLine(
|
||||||
|
`extra.handlers[${nodeID}] = extra.handlers[${nodeID}] || context['${handler}'].bind(owner);`
|
||||||
);
|
);
|
||||||
ctx.addLine(`p${nodeID}.on = {${eventName}: extra.handlers[${nodeID}]};`);
|
ctx.addLine(`p${nodeID}.on = {${eventName}: extra.handlers[${nodeID}]};`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const refDirective: Directive = {
|
const refDirective: Directive = {
|
||||||
|
|||||||
@@ -904,8 +904,7 @@ exports[`t-on can bind handlers with arguments 1`] = `
|
|||||||
let h = this.h;
|
let h = this.h;
|
||||||
let c1 = [], p1 = {};
|
let c1 = [], p1 = {};
|
||||||
let vn1 = h('button', p1, c1);
|
let vn1 = h('button', p1, c1);
|
||||||
extra.handlers[1] = extra.handlers[1] || context['add'].bind(owner, 5);
|
p1.on = {click: context['add'].bind(owner, 5)};
|
||||||
p1.on = {click: extra.handlers[1]};
|
|
||||||
c1.push({text: \`Click\`});
|
c1.push({text: \`Click\`});
|
||||||
return vn1;
|
return vn1;
|
||||||
}"
|
}"
|
||||||
@@ -939,8 +938,7 @@ exports[`t-on can bind handlers with loop variable as argument 1`] = `
|
|||||||
let c6 = [], p6 = {};
|
let c6 = [], p6 = {};
|
||||||
let vn6 = h('a', p6, c6);
|
let vn6 = h('a', p6, c6);
|
||||||
c5.push(vn6);
|
c5.push(vn6);
|
||||||
extra.handlers[6] = extra.handlers[6] || context['activate'].bind(owner, context['action']);
|
p6.on = {click: context['activate'].bind(owner, context['action'])};
|
||||||
p6.on = {click: extra.handlers[6]};
|
|
||||||
c6.push({text: \`link\`});
|
c6.push({text: \`link\`});
|
||||||
}
|
}
|
||||||
c1.push({text: \`
|
c1.push({text: \`
|
||||||
|
|||||||
Reference in New Issue
Block a user