mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] qweb: t-call should protect scope and let it accessible
Have a t-call nested in a t-foreach nested in a t-foreach
```xml
<t t-name="template">
<t t-foreach="..." t-as="a">
<t t-foreach="..." t-as="b">
<t-call="templateCalled" />
</t>
</t>
</t>
```
Before this commit, the `a` variable was not accessible within the t-call.
That was because the way t-call protected its scope by hiding other protected scope
in this case, the first protected scope for the first `t-foreach` was hidden
After this commit, `a` and `b` are accessible in the t-call, whether the t-call
defines its own variables by `t-set` or not.
Also, as expected from other fixes, there is no leaks of variables defined within a `t-call`
fixes #695
This commit is contained in:
committed by
Géry Debongnie
parent
c5a2f52afb
commit
8e03f9cd9c
@@ -1253,12 +1253,16 @@ exports[`other directives with t-component t-set can't alter from within callee
|
||||
if (scope.iter != null) {
|
||||
c2.push({text: scope.iter});
|
||||
}
|
||||
this.constructor.subTemplates['2'].call(this, Object.assign(Object.create(context), scope), Object.assign({}, extra, {parentNode: c1, parent: utils.getComponent(context), key: '__4__'}));
|
||||
let c5 = [], p5 = {key:5};
|
||||
let vn5 = h('p', p5, c5);
|
||||
c1.push(vn5);
|
||||
let _origScope4 = scope;
|
||||
scope = Object.create(scope);
|
||||
scope.__access_mode__ = 'ro';
|
||||
this.constructor.subTemplates['2'].call(this, scope, Object.assign({}, extra, {parentNode: c1, parent: utils.getComponent(context), key: '__5__'}));
|
||||
scope = _origScope4;
|
||||
let c6 = [], p6 = {key:6};
|
||||
let vn6 = h('p', p6, c6);
|
||||
c1.push(vn6);
|
||||
if (scope.iter != null) {
|
||||
c5.push({text: scope.iter});
|
||||
c6.push({text: scope.iter});
|
||||
}
|
||||
return vn1;
|
||||
}"
|
||||
@@ -1280,18 +1284,18 @@ exports[`other directives with t-component t-set can't alter in t-call body 1`]
|
||||
if (scope.iter != null) {
|
||||
c2.push({text: scope.iter});
|
||||
}
|
||||
let _origScope4 = scope;
|
||||
scope = Object.create(scope);
|
||||
scope.__access_mode__ = 'ro';
|
||||
{
|
||||
let _origScope4 = scope;
|
||||
scope = Object.create(scope);
|
||||
scope.__access_mode__ = 'ro';
|
||||
{
|
||||
let c__0 = [];
|
||||
utils.getScope(scope, 'iter').iter = 'inCall';
|
||||
scope[utils.zero] = c__0;
|
||||
}
|
||||
this.constructor.subTemplates['2'].call(this, scope, Object.assign({}, extra, {parentNode: c1, parent: utils.getComponent(context), key: '__5__'}));
|
||||
scope = _origScope4;
|
||||
}
|
||||
scope = _origScope4;
|
||||
let c6 = [], p6 = {key:6};
|
||||
let vn6 = h('p', p6, c6);
|
||||
c1.push(vn6);
|
||||
@@ -1410,7 +1414,11 @@ exports[`random stuff/miscellaneous can inject values in tagged templates 1`] =
|
||||
let h = this.h;
|
||||
let c1 = [], p1 = {key:1};
|
||||
let vn1 = h('div', p1, c1);
|
||||
this.constructor.subTemplates['3'].call(this, Object.assign(Object.create(context), scope), Object.assign({}, extra, {parentNode: c1, parent: utils.getComponent(context), key: '__4__'}));
|
||||
let _origScope4 = scope;
|
||||
scope = Object.create(scope);
|
||||
scope.__access_mode__ = 'ro';
|
||||
this.constructor.subTemplates['3'].call(this, scope, Object.assign({}, extra, {parentNode: c1, parent: utils.getComponent(context), key: '__5__'}));
|
||||
scope = _origScope4;
|
||||
return vn1;
|
||||
}"
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user