fix(ivy): better support for i18n attributes on <ng-container>s (#33599)

Prior to this commit, i18n runtime logic used `elementAttributeInternal` function (that uses `setAttribute` function under the hood) for all elements where i18n attributes are present. However the `<ng-container>` elements in a template may also have i18n attributes and calling `setAttribute` fails, since they are represented as comment nodes in DOM. This commit ensures that we call `setAttribute` on nodes with TNodeType.Element type (that support that operation) only.

PR Close #33599
This commit is contained in:
Andrew Kushnir
2019-11-05 11:12:27 -08:00
committed by Andrew Scott
parent 3419b5002f
commit 204620291e
2 changed files with 33 additions and 2 deletions

View File

@ -1011,9 +1011,13 @@ function i18nAttributesFirstPass(lView: LView, tView: TView, index: number, valu
generateBindingUpdateOpCodes(value, previousElementIndex, attrName), updateOpCodes);
}
} else {
elementAttributeInternal(previousElementIndex, attrName, value, lView);
// Check if that attribute is a directive input
const tNode = getTNode(previousElementIndex, lView);
// Set attributes for Elements only, for other types (like ElementContainer),
// only set inputs below
if (tNode.type === TNodeType.Element) {
elementAttributeInternal(previousElementIndex, attrName, value, lView);
}
// Check if that attribute is a directive input
const dataValue = tNode.inputs && tNode.inputs[attrName];
if (dataValue) {
setInputsForProperty(lView, dataValue, value);