mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] t-call-context: fix capture making component available in ctx
Previously, when using a component with a slot within a t-call with t-call-context, the component would become available again inside the slot despite the t-call-context. This was caused by the fact that the capture helper function creates an object with the component as its prototype which is incorrect. It should just use the previous context as its prototype.
This commit is contained in:
committed by
Géry Debongnie
parent
39329f80b2
commit
3d40533de1
@@ -1140,7 +1140,7 @@ export class CodeGenerator {
|
||||
if (this.target.loopLevel || !this.hasSafeContext) {
|
||||
ctxStr = generateId("ctx");
|
||||
this.helpers.add("capture");
|
||||
this.define(ctxStr, `capture(ctx, this)`);
|
||||
this.define(ctxStr, `capture(ctx)`);
|
||||
}
|
||||
let slotStr: string[] = [];
|
||||
for (let slotName in ast.slots) {
|
||||
@@ -1316,7 +1316,7 @@ export class CodeGenerator {
|
||||
if (this.target.loopLevel || !this.hasSafeContext) {
|
||||
ctxStr = generateId("ctx");
|
||||
this.helpers.add("capture");
|
||||
this.define(ctxStr, `capture(ctx, this)`);
|
||||
this.define(ctxStr, `capture(ctx)`);
|
||||
}
|
||||
let id = generateId("comp");
|
||||
this.staticDefs.push({
|
||||
|
||||
@@ -46,8 +46,8 @@ function callSlot(
|
||||
return slotBDom || text("");
|
||||
}
|
||||
|
||||
function capture(ctx: any, component: any): any {
|
||||
const result = ObjectCreate(component);
|
||||
function capture(ctx: any): any {
|
||||
const result = ObjectCreate(ctx);
|
||||
for (let k in ctx) {
|
||||
result[k] = ctx[k];
|
||||
}
|
||||
@@ -114,7 +114,7 @@ class LazyValue {
|
||||
|
||||
constructor(fn: any, ctx: any, component: any, node: any, key: any) {
|
||||
this.fn = fn;
|
||||
this.ctx = capture(ctx, component);
|
||||
this.ctx = capture(ctx);
|
||||
this.component = component;
|
||||
this.node = node;
|
||||
this.key = key;
|
||||
|
||||
Reference in New Issue
Block a user