fix(ivy): handle expressions in i18n attributes properly (#32309)
Prior to this commit, complex expressions (that require additional statements to be generated) were handled incorrectly in case they were used in attributes annotated with i18n flags. The problem was caused by the fact that extra statements were not appended to the temporary vars block, so they were missing in generated code. This commit updated the logic to use the `convertPropertyBinding`, which contains the necessary code to append extra statements. The `convertExpressionBinding` function was removed as it duplicates the `convertPropertyBinding` one (for the most part) and is no longer used. PR Close #32309
This commit is contained in:

committed by
Matias Niemelä

parent
36d613dd67
commit
f00d03356f
@ -664,7 +664,7 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
|
||||
hasBindings = true;
|
||||
bindings.push({
|
||||
sourceSpan: element.sourceSpan,
|
||||
value: () => this.convertExpressionBinding(expression)
|
||||
value: () => this.convertPropertyBinding(expression)
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -1155,19 +1155,12 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
|
||||
this._bindingScope.getOrCreateSharedContextVar(0);
|
||||
}
|
||||
|
||||
private convertExpressionBinding(value: AST): o.Expression {
|
||||
const convertedPropertyBinding = convertPropertyBinding(
|
||||
this, this.getImplicitReceiverExpr(), value, this.bindingContext(), BindingForm.TrySimple);
|
||||
return convertedPropertyBinding.currValExpr;
|
||||
}
|
||||
|
||||
private convertPropertyBinding(value: AST): o.Expression {
|
||||
const convertedPropertyBinding = convertPropertyBinding(
|
||||
this, this.getImplicitReceiverExpr(), value, this.bindingContext(), BindingForm.TrySimple,
|
||||
() => error('Unexpected interpolation'));
|
||||
const valExpr = convertedPropertyBinding.currValExpr;
|
||||
this._tempVariables.push(...convertedPropertyBinding.stmts);
|
||||
|
||||
return valExpr;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user