[FIX] compiler: do not look up ComponentNode in the context

With the introduction of t-call-context, there is now no guarantee that
the ComponentNode can be found in the rendering context, any attempt to
do so can crash when combined with t-call-context. This commit fixes
that by using `this` instead, which in compiled templates refers to the
component that is being rendered.
This commit is contained in:
Samuel Degueldre
2022-11-18 10:13:57 +01:00
committed by Géry Debongnie
parent 3d49daedcd
commit 9a5edb4590
18 changed files with 337 additions and 234 deletions
@@ -283,7 +283,7 @@ exports[`bound functions is referentially equal after update 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") {
return comp1({val: ctx['state'].val,fn: bind(ctx, ctx['someFunction'])}, key + \`__1\`, node, this, null);
return comp1({val: ctx['state'].val,fn: bind(this, ctx['someFunction'])}, key + \`__1\`, node, this, null);
}
}"
`;
@@ -307,7 +307,7 @@ exports[`can bind function prop with bind suffix 1`] = `
const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") {
return comp1({doSomething: bind(ctx, ctx['doSomething'])}, key + \`__1\`, node, this, null);
return comp1({doSomething: bind(this, ctx['doSomething'])}, key + \`__1\`, node, this, null);
}
}"
`;