mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] slots: allow t-call and components in slot default content
This commit is contained in:
committed by
Aaron Bohy
parent
5d8141a67c
commit
3f66d9fe6c
@@ -19,7 +19,7 @@ function callSlot(
|
||||
name: string,
|
||||
dynamic: boolean,
|
||||
extra: any,
|
||||
defaultSlot?: (ctx: any, key: string) => BDom
|
||||
defaultContent?: (ctx: any, node: any, key: string) => BDom
|
||||
): BDom {
|
||||
const slots = (ctx.props && ctx.props.slots) || {};
|
||||
const { __render, __ctx, __scope } = slots[name] || {};
|
||||
@@ -28,13 +28,13 @@ function callSlot(
|
||||
slotScope[__scope] = extra || {};
|
||||
}
|
||||
const slotBDom = __render ? __render(slotScope, parent, key) : null;
|
||||
if (defaultSlot) {
|
||||
if (defaultContent) {
|
||||
let child1: BDom | undefined = undefined;
|
||||
let child2: BDom | undefined = undefined;
|
||||
if (slotBDom) {
|
||||
child1 = dynamic ? toggler(name, slotBDom) : slotBDom;
|
||||
} else {
|
||||
child2 = defaultSlot(parent, key);
|
||||
child2 = defaultContent(ctx, parent, key);
|
||||
}
|
||||
return multi([child1, child2]);
|
||||
}
|
||||
|
||||
@@ -1095,9 +1095,9 @@ export class CodeGenerator {
|
||||
}
|
||||
|
||||
if (ast.defaultContent) {
|
||||
let name = this.generateId("defaultSlot");
|
||||
let name = this.generateId("defaultContent");
|
||||
const slot = new CodeTarget(name);
|
||||
slot.signature = "ctx => {";
|
||||
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