[FIX] slots: process slot params/values like normal props

This commit is contained in:
Géry Debongnie
2022-02-08 09:57:49 +01:00
committed by Aaron Bohy
parent ea2ccc5a03
commit 3196b585fd
13 changed files with 211 additions and 50 deletions
@@ -75,6 +75,37 @@ exports[`slots can define and call slots 2`] = `
}"
`;
exports[`slots can define and call slots with bound params 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { capture, bind } = helpers;
function slot1(ctx, node, key = \\"\\") {
return text(\`abc\`);
}
return function template(ctx, node, key = \\"\\") {
const ctx1 = capture(ctx);
return component(\`Child\`, {slots: {'abc': {__render: slot1, __ctx: ctx1, getValue: bind(ctx, ctx['getValue'])}}}, key + \`__1\`, node, ctx);
}
}"
`;
exports[`slots can define and call slots with bound params 2`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
let b2 = callSlot(ctx, node, key, 'abc', false, {});
let b3 = text(ctx['props'].slots['abc'].getValue());
return multi([b2, b3]);
}
}"
`;
exports[`slots can define and call slots with params 1`] = `
"function anonymous(bdom, helpers
) {
@@ -424,6 +455,33 @@ exports[`slots default slot next to named slot, with default content 2`] = `
}"
`;
exports[`slots default slot with params with - in it 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
function slot1(ctx, node, key = \\"\\") {
return text(ctx['slotScope']['some-value']);
}
return function template(ctx, node, key = \\"\\") {
return component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx, __scope: \\"slotScope\\"}}}, key + \`__1\`, node, ctx);
}
}"
`;
exports[`slots default slot with params with - in it 2`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { callSlot } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {'some-value': ctx['state'].value});
}
}"
`;
exports[`slots default slot with slot scope: shorthand syntax 1`] = `
"function anonymous(bdom, helpers
) {
@@ -1207,6 +1265,33 @@ exports[`slots simple default slot with params 2`] = `
}"
`;
exports[`slots simple default slot with params and bound function 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
function slot1(ctx, node, key = \\"\\") {
return text(ctx['slotScope'].fn());
}
return function template(ctx, node, key = \\"\\") {
return component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx, __scope: \\"slotScope\\"}}}, key + \`__1\`, node, ctx);
}
}"
`;
exports[`slots simple default slot with params and bound function 2`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { callSlot, bind } = helpers;
return function template(ctx, node, key = \\"\\") {
return callSlot(ctx, node, key, 'default', false, {fn: bind(ctx, ctx['getValue'])});
}
}"
`;
exports[`slots simple default slot, variation 1`] = `
"function anonymous(bdom, helpers
) {