mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] slots: properly bind this in t-on arrow functions
This commit is contained in:
committed by
Aaron Bohy
parent
05a57d6da5
commit
2601a176c4
@@ -27,14 +27,14 @@ function callSlot(
|
||||
if (__scope) {
|
||||
slotScope[__scope] = extra || {};
|
||||
}
|
||||
const slotBDom = __render ? __render(slotScope, parent, key) : null;
|
||||
const slotBDom = __render ? __render.call(__ctx.__owl__.component, slotScope, parent, key) : null;
|
||||
if (defaultContent) {
|
||||
let child1: BDom | undefined = undefined;
|
||||
let child2: BDom | undefined = undefined;
|
||||
if (slotBDom) {
|
||||
child1 = dynamic ? toggler(name, slotBDom) : slotBDom;
|
||||
} else {
|
||||
child2 = defaultContent(ctx, parent, key);
|
||||
child2 = defaultContent.call(ctx.__owl__.component, ctx, parent, key);
|
||||
}
|
||||
return multi([child1, child2]);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,6 @@ function createContext(parentCtx: Context, params?: Partial<Context>) {
|
||||
|
||||
class CodeTarget {
|
||||
name: string;
|
||||
signature: string = "";
|
||||
indentLevel = 0;
|
||||
loopLevel = 0;
|
||||
code: string[] = [];
|
||||
@@ -334,7 +333,7 @@ export class CodeGenerator {
|
||||
|
||||
generateFunctions(fn: CodeTarget) {
|
||||
this.addLine("");
|
||||
this.addLine(`const ${fn.name} = ${fn.signature}`);
|
||||
this.addLine(`function ${fn.name}(ctx, node, key) {`);
|
||||
if (fn.hasCache) {
|
||||
this.addLine(`let cache = ctx.cache || {};`);
|
||||
this.addLine(`let nextCache = ctx.cache = {};`);
|
||||
@@ -988,7 +987,6 @@ export class CodeGenerator {
|
||||
for (let slotName in ast.slots) {
|
||||
let name = this.generateId("slot");
|
||||
const slot = new CodeTarget(name);
|
||||
slot.signature = "(ctx, node, key) => {";
|
||||
this.functions.push(slot);
|
||||
this.target = slot;
|
||||
const subCtx: Context = createContext(ctx);
|
||||
@@ -1097,7 +1095,6 @@ export class CodeGenerator {
|
||||
if (ast.defaultContent) {
|
||||
let name = this.generateId("defaultContent");
|
||||
const slot = new CodeTarget(name);
|
||||
slot.signature = "(ctx, node, key) => {";
|
||||
this.functions.push(slot);
|
||||
const initialTarget = this.target;
|
||||
const subCtx: Context = createContext(ctx);
|
||||
|
||||
Reference in New Issue
Block a user