Skip to content

Commit

Permalink
feat(compiler): allow trailing comma in array literal (#22277)
Browse files Browse the repository at this point in the history
Allows `[1, 2, ]` syntax in angular expressions.

closes #20773

PR Close #22277
  • Loading branch information
trotyl authored and mhevery committed Dec 2, 2020
1 parent efd0d33 commit 8d613c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/compiler/src/expression_parser/parser.ts
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions packages/compiler/test/expression_parser/parser_spec.ts
Expand Up @@ -106,6 +106,7 @@ describe('parser', () => {
checkAction('[]');
checkAction('[].length');
checkAction('[1, 2].length');
checkAction('[1, 2,]', '[1, 2]');
});

it('should parse map', () => {
Expand Down

0 comments on commit 8d613c1

Please sign in to comment.