fix(compiler): avoid generating i18n attributes in plain form (#36422)

Prior to this change, there was a problem while matching template attributes, which mistakenly took i18n attributes (that might be present in attrs array after template ones) into account. This commit updates the logic to avoid template attribute matching logic from entering the i18n section and as a result this also allows generating proper i18n attributes sections instead of keeping these attribute in plain form (with their values) in attribute arrays.

PR Close #36422
This commit is contained in:
Andrew Kushnir
2020-04-03 12:58:20 -07:00
committed by atscott
parent 1d4af3f734
commit 08b8b51486
6 changed files with 54 additions and 20 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {escapeRegExp, splitAtColon, stringify, utf8Encode} from '../src/util';
import {escapeRegExp, partitionArray, splitAtColon, stringify, utf8Encode} from '../src/util';
{
describe('util', () => {
@ -83,5 +83,21 @@ import {escapeRegExp, splitAtColon, stringify, utf8Encode} from '../src/util';
expect(stringify(Object.create(null))).toEqual('object');
});
});
describe('partitionArray()', () => {
it('should handle empty arrays', () => {
expect(partitionArray([], () => true)).toEqual([[], []]);
});
it('should handle arrays with primitive type values', () => {
expect(partitionArray([1, 2, 3], (el: number) => el < 2)).toEqual([[1], [2, 3]]);
});
it('should handle arrays of objects', () => {
expect(partitionArray([{id: 1}, {id: 2}, {id: 3}], (el: any) => el.id < 2)).toEqual([
[{id: 1}], [{id: 2}, {id: 3}]
]);
});
});
});
}