fix(compiler): Don’t throw on empty property bindings

Closes #12583
This commit is contained in:
Tobias Bosch 2016-10-28 14:08:29 -07:00 committed by vsavkin
parent 579deeb9c5
commit 642c1db9ef
2 changed files with 11 additions and 0 deletions

View File

@ -54,6 +54,9 @@ export function bindRenderInputs(
view.detectChangesRenderPropertiesMethod.resetDebugInfo(compileElement.nodeIndex, boundProp); view.detectChangesRenderPropertiesMethod.resetDebugInfo(compileElement.nodeIndex, boundProp);
const evalResult = convertPropertyBinding( const evalResult = convertPropertyBinding(
view, view, compileElement.view.componentContext, boundProp.value, bindingField.bindingId); view, view, compileElement.view.componentContext, boundProp.value, bindingField.bindingId);
if (!evalResult) {
return;
}
var checkBindingStmts: o.Statement[] = []; var checkBindingStmts: o.Statement[] = [];
var compileMethod = view.detectChangesRenderPropertiesMethod; var compileMethod = view.detectChangesRenderPropertiesMethod;
switch (boundProp.type) { switch (boundProp.type) {

View File

@ -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(() => { it('should support interpolation', fakeAsync(() => {
var ctx = _bindSimpleProp('someProp="B{{a}}A"', TestData); var ctx = _bindSimpleProp('someProp="B{{a}}A"', TestData);
ctx.componentInstance.a = 'value'; ctx.componentInstance.a = 'value';