fix(ivy): proper accounting of bound vars in i18nExp fns (FW-747) (#27338)

The problem was caused by missing `allocateBindingSlots` that led to incorrect # of vars defined for components and as a result, causing errors at runtime. Now all `bind` operation are accounted for and the number of `vars` is correct.

PR Close #27338
This commit is contained in:
Andrew Kushnir
2018-11-28 17:31:21 -08:00
committed by Igor Minar
parent 973ebdc0ea
commit 01fd0cd878
2 changed files with 83 additions and 22 deletions

View File

@ -285,6 +285,7 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
bound[key] = o.literal(prop.value);
} else {
const value = prop.value.visit(this._valueConverter);
this.allocateBindingSlots(value);
if (value instanceof Interpolation) {
const {strings, expressions} = value;
const {id, bindings} = this.i18n !;
@ -563,6 +564,7 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
i18nAttrArgs.push(o.literal(attr.name), this.i18nTranslate(message));
} else {
const converted = attr.value.visit(this._valueConverter);
this.allocateBindingSlots(converted);
if (converted instanceof Interpolation) {
const placeholders = assembleBoundTextPlaceholders(message);
const params = placeholdersToParams(placeholders);
@ -752,6 +754,7 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
visitBoundText(text: t.BoundText) {
if (this.i18n) {
const value = text.value.visit(this._valueConverter);
this.allocateBindingSlots(value);
if (value instanceof Interpolation) {
this.i18n.appendBoundText(text.i18n !);
this.i18nAppendBindings(value.expressions);