fix(Compiler): Catch exceptions in the logging of binding update

fixes #9994
This commit is contained in:
Victor Berchet
2016-07-12 10:26:54 -07:00
parent b4ea0b1601
commit 27436270fd
5 changed files with 48 additions and 28 deletions
+4 -7
View File
@@ -69,16 +69,13 @@ export abstract class Renderer {
abstract setBindingDebugInfo(renderElement: any, propertyName: string, propertyValue: string):
void;
abstract setElementClass(renderElement: any, className: string, isAdd: boolean): any
/** TODO #9100 */;
abstract setElementClass(renderElement: any, className: string, isAdd: boolean): void;
abstract setElementStyle(renderElement: any, styleName: string, styleValue: string): any
/** TODO #9100 */;
abstract setElementStyle(renderElement: any, styleName: string, styleValue: string): void;
abstract invokeElementMethod(renderElement: any, methodName: string, args?: any[]): any
/** TODO #9100 */;
abstract invokeElementMethod(renderElement: any, methodName: string, args?: any[]): void;
abstract setText(renderNode: any, text: string): any /** TODO #9100 */;
abstract setText(renderNode: any, text: string): void;
abstract animate(
element: any, startingStyles: AnimationStyles, keyframes: AnimationKeyframe[],
@@ -1846,6 +1846,21 @@ function declareTests({useJit}: {useJit: boolean}) {
async.done();
});
}));
it('should indicate when toString() throws',
inject(
[TestComponentBuilder, AsyncTestCompleter],
(tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
var tpl = '<div my-dir [elprop]="toStringThrow"></div>';
tcb.overrideView(MyComp, new ViewMetadata({template: tpl, directives: [MyDir]}))
.createAsync(MyComp)
.then((fixture) => {
fixture.detectChanges();
expect(getDOM().getInnerHTML(fixture.debugElement.nativeElement))
.toContain('[ERROR]');
async.done();
});
}));
});
describe('property decorators', () => {
@@ -2227,6 +2242,8 @@ class MyComp {
ctxProp: string;
ctxNumProp: number;
ctxBoolProp: boolean;
toStringThrow = {toString: function() { throw 'boom'; }};
constructor() {
this.ctxProp = 'initial value';
this.ctxNumProp = 0;