[IMP] components: slots can now define default content

closes #554
This commit is contained in:
Géry Debongnie
2019-12-10 15:03:14 +01:00
committed by aab-odoo
parent 9145799ae9
commit bc455be720
4 changed files with 124 additions and 1 deletions
+7 -1
View File
@@ -194,7 +194,7 @@ QWeb.addDirective({
QWeb.addDirective({
name: "slot",
priority: 80,
atNodeEncounter({ ctx, value }): boolean {
atNodeEncounter({ ctx, value, node, qweb }): boolean {
const slotKey = ctx.generateID();
ctx.addLine(
`const slot${slotKey} = this.constructor.slots[context.__owl__.slotId + '_' + '${value}'];`
@@ -214,6 +214,12 @@ QWeb.addDirective({
if (!ctx.parentNode) {
ctx.addLine(`utils.defineProxy(result, ${parentNode}[0]);`);
}
if (node.hasChildNodes()) {
ctx.addElse();
const nodeCopy = <Element>node.cloneNode(true);
nodeCopy.removeAttribute("t-slot");
qweb._compileNode(nodeCopy, ctx);
}
ctx.closeIf();
return true;
}