Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
fix(NgComponent): Handle errors while loading CSS
Browse files Browse the repository at this point in the history
Closes #411
  • Loading branch information
mhevery committed Feb 6, 2014
1 parent 2645fa9 commit b5aa130
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/core_dom/block_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ class _ComponentFactory {
List<async.Future<String>> cssFutures = new List();
var cssUrls = component.cssUrls;
if (cssUrls.isNotEmpty) {
cssUrls.forEach((css) => cssFutures.add( $http.getString(css, cache: $templateCache) ) );
cssUrls.forEach((css) => cssFutures.add(
$http.getString(css, cache: $templateCache).catchError((e) => '/*\n$e\n*/\n')
) );
} else {
cssFutures.add( new async.Future.value(null) );
}
Expand Down
16 changes: 16 additions & 0 deletions test/core/templateurl_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ main() => describe('template url', () {
expect(renderedText(element)).toEqual('.hello{}inline!');
})));

it('should ignore CSS load errors ', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Injector injector,
MockHttpBackend backend, DirectiveMap directives) {
var element = $('<div><inline-with-css log>ignore</inline-with-css><div>');
backend.expectGET('simple.css').respond(500, 'some error');
$compile(element, directives)(injector, element);

backend.flush();
microLeap();
expect(renderedText(element)).toEqual(
'/*\n'
'HTTP 500: some error\n'
'*/\n'
'inline!');
})));

it('should load a CSS with no template', async(inject((Http $http,
Compiler $compile, Scope $rootScope, Injector injector,
MockHttpBackend backend, DirectiveMap directives) {
Expand Down

0 comments on commit b5aa130

Please sign in to comment.