From b4613ab2d26b0546699bad1afd7c9441b324382f Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Thu, 4 Aug 2016 17:04:30 -0700 Subject: [PATCH] fix(ExpressionParser): undefined is undefined (was null) --- modules/@angular/compiler/src/expression_parser/parser.ts | 7 ++++++- .../compiler/test/expression_parser/parser_spec.ts | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/@angular/compiler/src/expression_parser/parser.ts b/modules/@angular/compiler/src/expression_parser/parser.ts index d72d1b4213..049c5eeae0 100644 --- a/modules/@angular/compiler/src/expression_parser/parser.ts +++ b/modules/@angular/compiler/src/expression_parser/parser.ts @@ -511,10 +511,15 @@ export class _ParseAST { this.rparensExpected--; this.expectCharacter(chars.$RPAREN); return result; - } else if (this.next.isKeywordNull() || this.next.isKeywordUndefined()) { + + } else if (this.next.isKeywordNull()) { this.advance(); return new LiteralPrimitive(this.span(start), null); + } else if (this.next.isKeywordUndefined()) { + this.advance(); + return new LiteralPrimitive(this.span(start), void 0); + } else if (this.next.isKeywordTrue()) { this.advance(); return new LiteralPrimitive(this.span(start), true); diff --git a/modules/@angular/compiler/test/expression_parser/parser_spec.ts b/modules/@angular/compiler/test/expression_parser/parser_spec.ts index ffd17e4dd1..bbf425ab50 100644 --- a/modules/@angular/compiler/test/expression_parser/parser_spec.ts +++ b/modules/@angular/compiler/test/expression_parser/parser_spec.ts @@ -92,6 +92,8 @@ export function main() { it('should parse null', () => { checkAction('null'); }); + it('should parse undefined', () => { checkAction('undefined'); }); + it('should parse unary - expressions', () => { checkAction('-1', '0 - 1'); checkAction('+1', '1');