[FIX] compiler: call dynamic templates with correct this

This commit is contained in:
Géry Debongnie
2021-11-25 17:22:31 +01:00
committed by Mathieu Duckerts-Antoine
parent 13c3178760
commit a1d435c5a5
6 changed files with 61 additions and 6 deletions
@@ -2388,7 +2388,7 @@ exports[`slots t-slot within dynamic t-call 4`] = `
function slot2(ctx, node, key) {
const template4 = (ctx['tcallTemplate']);
return call(template4, ctx, node, key + \`__3\`);
return call(this, template4, ctx, node, key + \`__3\`);
}
return function template(ctx, node, key = \\"\\") {
@@ -12,7 +12,7 @@ exports[`t-call dynamic t-call 1`] = `
let b1 = text(\` owl \`);
ctx[zero] = b1;
const template2 = (ctx['current'].template);
return call(template2, ctx, node, key + \`__1\`);
return call(this, template2, ctx, node, key + \`__1\`);
}
}"
`;
@@ -43,6 +43,38 @@ exports[`t-call dynamic t-call 3`] = `
}"
`;
exports[`t-call handlers are properly bound through a dynamic t-call 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;
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = [()=>this.update(), ctx];
return block1([d1]);
}
}"
`;
exports[`t-call handlers are properly bound through a dynamic t-call 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;
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
const template2 = ('__template__9');
let b2 = call(this, template2, ctx, node, key + \`__1\`);
let d1 = ctx['counter'];
return block1([d1], [b2]);
}
}"
`;
exports[`t-call handlers are properly bound through a t-call 1`] = `
"function anonymous(bdom, helpers
) {