qweb: make sure on directive is properly bound

This commit is contained in:
Géry Debongnie
2019-01-25 16:00:32 +01:00
parent c3221663a9
commit 6f6e2d887d
2 changed files with 33 additions and 66 deletions
+2 -1
View File
@@ -194,6 +194,7 @@ export class QWeb {
const ctx = new Context();
// this is necessary to prevent some directives (t-forach for ex) to
// pollute the rendering context by adding some keys in it.
ctx.addLine("let owner = context");
ctx.addLine("context = Object.create(context)");
const mainNode = doc.firstChild!;
this._compileNode(mainNode, ctx);
@@ -652,7 +653,7 @@ const onDirective: Directive = {
return "";
});
ctx.addLine(
`p${nodeID}.on = {${eventName}: context['${handler}'].bind(context${
`p${nodeID}.on = {${eventName}: context['${handler}'].bind(owner${
extraArgs ? ", " + qweb._formatExpression(extraArgs) : ""
})}`
);