diff --git a/src/app/template_helpers.ts b/src/app/template_helpers.ts
index fa29c95f..fe055377 100644
--- a/src/app/template_helpers.ts
+++ b/src/app/template_helpers.ts
@@ -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]);
}
diff --git a/src/compiler/code_generator.ts b/src/compiler/code_generator.ts
index 69c2d2f9..f77360f7 100644
--- a/src/compiler/code_generator.ts
+++ b/src/compiler/code_generator.ts
@@ -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);
diff --git a/tests/components/__snapshots__/slots.test.ts.snap b/tests/components/__snapshots__/slots.test.ts.snap
index b1c8c4a9..60f49e18 100644
--- a/tests/components/__snapshots__/slots.test.ts.snap
+++ b/tests/components/__snapshots__/slots.test.ts.snap
@@ -133,6 +133,87 @@ exports[`slots can render only empty slot 1`] = `
}"
`;
+exports[`slots can use component in default-content of t-slot 1`] = `
+"function anonymous(bdom, helpers
+) {
+ let { text, createBlock, list, multi, html, toggler, component } = bdom;
+ let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
+
+ return function template(ctx, node, key = \\"\\") {
+ return text(\`\`);
+ }
+}"
+`;
+
+exports[`slots can use component in default-content of t-slot 2`] = `
+"function anonymous(bdom, helpers
+) {
+ let { text, createBlock, list, multi, html, toggler, component } = bdom;
+ let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
+
+ const defaultContent1 = (ctx, node, key) => {
+ return component(\`GrandChild\`, {}, key + \`__2\`, node, ctx);
+ }
+
+ return function template(ctx, node, key = \\"\\") {
+ return callSlot(ctx, node, key, 'default', false, {}, defaultContent1);
+ }
+}"
+`;
+
+exports[`slots can use component in default-content of t-slot 3`] = `
+"function anonymous(bdom, helpers
+) {
+ let { text, createBlock, list, multi, html, toggler, component } = bdom;
+ let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
+
+ return function template(ctx, node, key = \\"\\") {
+ return component(\`Child\`, {}, key + \`__1\`, node, ctx);
+ }
+}"
+`;
+
+exports[`slots can use t-call in default-content of t-slot 1`] = `
+"function anonymous(bdom, helpers
+) {
+ let { text, createBlock, list, multi, html, toggler, component } = bdom;
+ let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
+
+ return function template(ctx, node, key = \\"\\") {
+ return text(\`\`);
+ }
+}"
+`;
+
+exports[`slots can use t-call in default-content of t-slot 2`] = `
+"function anonymous(bdom, helpers
+) {
+ let { text, createBlock, list, multi, html, toggler, component } = bdom;
+ let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
+ const callTemplate_3 = getTemplate(\`__template__9\`);
+
+ const defaultContent1 = (ctx, node, key) => {
+ return callTemplate_3.call(this, ctx, node, key + \`__2\`);
+ }
+
+ return function template(ctx, node, key = \\"\\") {
+ return callSlot(ctx, node, key, 'default', false, {}, defaultContent1);
+ }
+}"
+`;
+
+exports[`slots can use t-call in default-content of t-slot 3`] = `
+"function anonymous(bdom, helpers
+) {
+ let { text, createBlock, list, multi, html, toggler, component } = bdom;
+ let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
+
+ return function template(ctx, node, key = \\"\\") {
+ return component(\`Child\`, {}, key + \`__1\`, node, ctx);
+ }
+}"
+`;
+
exports[`slots content is the default slot (variation) 1`] = `
"function anonymous(bdom, helpers
) {
@@ -206,12 +287,12 @@ exports[`slots dafault slots can define a default content 1`] = `
let block1 = createBlock(\`