diff --git a/src/app/template_set.ts b/src/app/template_set.ts index a7f50766..a1d02409 100644 --- a/src/app/template_set.ts +++ b/src/app/template_set.ts @@ -51,9 +51,9 @@ export class TemplateSet { translateFn?: (s: string) => string; translatableAttributes?: string[]; utils: typeof UTILS = Object.assign({}, UTILS, { - call: (owner: any, subTemplate: string, ctx: any, parent: any) => { + call: (owner: any, subTemplate: string, ctx: any, parent: any, key: any) => { const template = this.getTemplate(subTemplate); - return toggler(subTemplate, template.call(owner, ctx, parent)); + return toggler(subTemplate, template.call(owner, ctx, parent, key)); }, getTemplate: (name: string) => this.getTemplate(name), }); diff --git a/tests/components/__snapshots__/t_call.test.ts.snap b/tests/components/__snapshots__/t_call.test.ts.snap index 34830b7a..5089c96b 100644 --- a/tests/components/__snapshots__/t_call.test.ts.snap +++ b/tests/components/__snapshots__/t_call.test.ts.snap @@ -41,6 +41,46 @@ exports[`t-call dynamic t-call 3`] = ` }" `; +exports[`t-call dynamic t-call: key is propagated 1`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component, comment } = bdom; + let { call } = helpers; + + return function template(ctx, node, key = \\"\\") { + let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx); + const template1 = (ctx['sub']); + let b3 = call(this, template1, ctx, node, key + \`__2\`); + return multi([b2, b3]); + } +}" +`; + +exports[`t-call dynamic t-call: key is propagated 2`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component, comment } = bdom; + + let block1 = createBlock(\`