From 6cd3326b55a7fdad015d8230e57e52633ebf47e2 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Mon, 6 Mar 2017 17:01:45 -0800 Subject: [PATCH] =?UTF-8?q?fix(compiler):=20don=E2=80=99t=20throw=20for=20?= =?UTF-8?q?empty=20array=20literal=20in=20assignments=20(#14878)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #14782 --- modules/@angular/compiler/src/expression_parser/ast.ts | 2 +- .../core/test/linker/change_detection_integration_spec.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/@angular/compiler/src/expression_parser/ast.ts b/modules/@angular/compiler/src/expression_parser/ast.ts index 8c5724ca11..87accce967 100644 --- a/modules/@angular/compiler/src/expression_parser/ast.ts +++ b/modules/@angular/compiler/src/expression_parser/ast.ts @@ -320,7 +320,7 @@ export class AstTransformer implements AstVisitor { } visitPropertyWrite(ast: PropertyWrite, context: any): AST { - return new PropertyWrite(ast.span, ast.receiver.visit(this), ast.name, ast.value); + return new PropertyWrite(ast.span, ast.receiver.visit(this), ast.name, ast.value.visit(this)); } visitSafePropertyRead(ast: SafePropertyRead, context: any): AST { diff --git a/modules/@angular/core/test/linker/change_detection_integration_spec.ts b/modules/@angular/core/test/linker/change_detection_integration_spec.ts index a4a2ffdefe..d092065fcd 100644 --- a/modules/@angular/core/test/linker/change_detection_integration_spec.ts +++ b/modules/@angular/core/test/linker/change_detection_integration_spec.ts @@ -619,6 +619,14 @@ export function main() { expect(ctx.componentInstance.a).toEqual(2); })); + it('should support empty literals', fakeAsync(() => { + const ctx = _bindSimpleProp('(event)="a=[{},[]]"'); + const childEl = ctx.debugElement.children[0]; + childEl.triggerEventHandler('event', 'EVENT'); + + expect(ctx.componentInstance.a).toEqual([{}, []]); + })); + it('should throw when trying to assign to a local', fakeAsync(() => { expect(() => { _bindSimpleProp('(event)="$event=1"');