[FIX] properly get component reference instead of context

Before this commit, the generated code for the component directive was
using the current context as the place to look for static informations
(such as the sub components). However, it is not entirely correct, since
the current context may be different than the current component (which
is easily accessed by using the this variable).

Also, while doing this, we fix some issues in the t-set directive, which
as calling lazy values with the wrong this.
This commit is contained in:
Géry Debongnie
2022-06-22 15:39:31 +02:00
parent e57e2ee378
commit 5772b4e9e4
29 changed files with 528 additions and 526 deletions
@@ -9,7 +9,7 @@ exports[`reactivity in lifecycle Child component doesn't render when state they
return function template(ctx, node, key = \\"\\") {
let b2;
if (ctx['state'].renderChild) {
b2 = comp1({state: ctx['state']}, key + \`__1\`, node, ctx, null);
b2 = comp1({state: ctx['state']}, key + \`__1\`, node, this, null);
}
return multi([b2]);
}
@@ -34,7 +34,7 @@ exports[`reactivity in lifecycle Component is automatically subscribed to reacti
const comp1 = app.createComponent(\`Child\`, true, false, false, false);
return function template(ctx, node, key = \\"\\") {
return comp1({obj: ctx['obj'],reactiveObj: ctx['reactiveObj']}, key + \`__1\`, node, ctx, null);
return comp1({obj: ctx['obj'],reactiveObj: ctx['reactiveObj']}, key + \`__1\`, node, this, null);
}
}"
`;
@@ -119,7 +119,7 @@ exports[`reactivity in lifecycle state changes in willUnmount do not trigger rer
return function template(ctx, node, key = \\"\\") {
let b2;
if (ctx['state'].flag) {
b2 = comp1({val: ctx['state'].val}, key + \`__1\`, node, ctx, null);
b2 = comp1({val: ctx['state'].val}, key + \`__1\`, node, this, null);
}
return block1([], [b2]);
}