From 642c1db9efb7f2c0b74b44d31fb8472666921d60 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Fri, 28 Oct 2016 14:08:29 -0700 Subject: [PATCH] =?UTF-8?q?fix(compiler):=20Don=E2=80=99t=20throw=20on=20e?= =?UTF-8?q?mpty=20property=20bindings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #12583 --- .../compiler/src/view_compiler/property_binder.ts | 3 +++ .../core/test/linker/change_detection_integration_spec.ts | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/modules/@angular/compiler/src/view_compiler/property_binder.ts b/modules/@angular/compiler/src/view_compiler/property_binder.ts index a9426893bc..dbf1f7d108 100644 --- a/modules/@angular/compiler/src/view_compiler/property_binder.ts +++ b/modules/@angular/compiler/src/view_compiler/property_binder.ts @@ -54,6 +54,9 @@ export function bindRenderInputs( view.detectChangesRenderPropertiesMethod.resetDebugInfo(compileElement.nodeIndex, boundProp); const evalResult = convertPropertyBinding( view, view, compileElement.view.componentContext, boundProp.value, bindingField.bindingId); + if (!evalResult) { + return; + } var checkBindingStmts: o.Statement[] = []; var compileMethod = view.detectChangesRenderPropertiesMethod; switch (boundProp.type) { 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 877ad2c98f..7294c2c9e3 100644 --- a/modules/@angular/core/test/linker/change_detection_integration_spec.ts +++ b/modules/@angular/core/test/linker/change_detection_integration_spec.ts @@ -427,6 +427,14 @@ export function main() { })); + it('should ignore empty bindings', fakeAsync(() => { + var ctx = _bindSimpleProp('[someProp]', TestData); + ctx.componentInstance.a = 'value'; + ctx.detectChanges(false); + + expect(renderLog.log).toEqual([]); + })); + it('should support interpolation', fakeAsync(() => { var ctx = _bindSimpleProp('someProp="B{{a}}A"', TestData); ctx.componentInstance.a = 'value';