feat(compiler): allow trailing comma in array literal (#22277)

Allows `[1, 2, ]` syntax in angular expressions.

closes #20773

PR Close #22277
This commit is contained in:
Trotyl 2018-02-18 00:05:41 +08:00 committed by Misko Hevery
parent efd0d33391
commit 8d613c1d42
2 changed files with 8 additions and 4 deletions

View File

@ -820,11 +820,14 @@ export class _ParseAST {
parseExpressionList(terminator: number): AST[] {
const result: AST[] = [];
if (!this.next.isCharacter(terminator)) {
do {
do {
if (!this.next.isCharacter(terminator)) {
result.push(this.parsePipe());
} while (this.consumeOptionalCharacter(chars.$COMMA));
}
} else {
break;
}
} while (this.consumeOptionalCharacter(chars.$COMMA));
return result;
}

View File

@ -106,6 +106,7 @@ describe('parser', () => {
checkAction('[]');
checkAction('[].length');
checkAction('[1, 2].length');
checkAction('[1, 2,]', '[1, 2]');
});
it('should parse map', () => {