fix(ivy): update i18n/i18nStart and i18nAttributes instruction order (#28163)

Prior to this change element's i18n attributes like "i18n-title" were processed after "i18n" ones that placed "i18n" and "i18nAttributes" instructions in wrong order, thus "i18nAttributes" failed to target its host element at runtime. This change updates processing order and puts "i18nAttributes" instructions in front of "i18n" ones to resolve the problem.

PR Close #28163
This commit is contained in:
Andrew Kushnir
2019-01-15 12:10:41 -08:00
parent c61ea1d5bd
commit 9a81f0d9a8
3 changed files with 17 additions and 16 deletions

View File

@ -619,10 +619,6 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
this.creationInstruction(element.sourceSpan, R3.disableBindings);
}
if (isI18nRootElement) {
this.i18nStart(element.sourceSpan, element.i18n !, createSelfClosingI18nInstruction);
}
// process i18n element attributes
if (i18nAttrs.length) {
let hasBindings: boolean = false;
@ -656,6 +652,12 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
}
}
// Note: it's important to keep i18n/i18nStart instructions after i18nAttributes ones,
// to make sure i18nAttributes instruction targets current element at runtime.
if (isI18nRootElement) {
this.i18nStart(element.sourceSpan, element.i18n !, createSelfClosingI18nInstruction);
}
// The style bindings code is placed into two distinct blocks within the template function AOT
// code: creation and update. The creation code contains the `elementStyling` instructions
// which will apply the collected binding values to the element. `elementStyling` is