From c3873be295c353ea50d1a91d35a324ce986c1b3c Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Tue, 3 Mar 2015 15:24:26 +0100 Subject: [PATCH] fix(Compiler): asynchronous error reporting --- .../angular2/src/core/compiler/compiler.js | 8 +++---- .../core/compiler/compiler_common_tests.js | 24 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/modules/angular2/src/core/compiler/compiler.js b/modules/angular2/src/core/compiler/compiler.js index 674c548a8c..d8a2eab95b 100644 --- a/modules/angular2/src/core/compiler/compiler.js +++ b/modules/angular2/src/core/compiler/compiler.js @@ -199,10 +199,10 @@ export class Compiler { var protoView = this._compile(ce.componentDirective.type); if (PromiseWrapper.isPromise(protoView)) { - ListWrapper.push(promises, protoView); - protoView.then(function (protoView) { - ce.inheritedElementBinder.nestedProtoView = protoView; - }); + ListWrapper.push( + promises, + protoView.then(function(pv) { ce.inheritedElementBinder.nestedProtoView = pv;}) + ); } else { ce.inheritedElementBinder.nestedProtoView = protoView; } diff --git a/modules/angular2/test/core/compiler/compiler_common_tests.js b/modules/angular2/test/core/compiler/compiler_common_tests.js index 37b042f9de..690ac250e8 100644 --- a/modules/angular2/test/core/compiler/compiler_common_tests.js +++ b/modules/angular2/test/core/compiler/compiler_common_tests.js @@ -229,19 +229,17 @@ export function runCompilerCommonTests() { createNestedComponentSpec('(error -> sync)', templateResolver, 'Failed to load the template for ParentComponent'); - // TODO(vicb): Check why errors this fails with Dart - // TODO(vicb): The Promise is rejected with the correct error but an exc is thrown before - //templateResolver = new FakeTemplateResolver(); - //templateResolver.setSync(ParentComponent); - //templateResolver.setError(NestedComponent); - //createNestedComponentSpec('(sync -> error)', templateResolver, - // 'Failed to load the template for NestedComponent -> Failed to compile ParentComponent'); - // - //templateResolver = new FakeTemplateResolver(); - //templateResolver.setAsync(ParentComponent); - //templateResolver.setError(NestedComponent); - //createNestedComponentSpec('(async -> error)', templateResolver, - // 'Failed to load the template for NestedComponent -> Failed to compile ParentComponent'); + templateResolver = new FakeTemplateResolver(); + templateResolver.setSync(ParentComponent); + templateResolver.setError(NestedComponent); + createNestedComponentSpec('(sync -> error)', templateResolver, + 'Failed to load the template for NestedComponent -> Failed to compile ParentComponent'); + + templateResolver = new FakeTemplateResolver(); + templateResolver.setAsync(ParentComponent); + templateResolver.setError(NestedComponent); + createNestedComponentSpec('(async -> error)', templateResolver, + 'Failed to load the template for NestedComponent -> Failed to compile ParentComponent'); });