diff --git a/modules/angular2/src/core/compiler/compiler.ts b/modules/angular2/src/core/compiler/compiler.ts index 4aee86ad9f..3795a1c0ae 100644 --- a/modules/angular2/src/core/compiler/compiler.ts +++ b/modules/angular2/src/core/compiler/compiler.ts @@ -301,7 +301,7 @@ export class Compiler { this._urlResolver.resolve(this._appUrl, this._componentUrlMapper.getUrl(component)); var templateAbsUrl = null; var styleAbsUrls = null; - if (isPresent(view.templateUrl)) { + if (isPresent(view.templateUrl) && view.templateUrl.trim().length > 0) { templateAbsUrl = this._urlResolver.resolve(componentUrl, view.templateUrl); } else if (isPresent(view.template)) { // Note: If we have an inline template, we also need to send diff --git a/modules/angular2/test/core/compiler/compiler_spec.ts b/modules/angular2/test/core/compiler/compiler_spec.ts index 5fa08b038a..a1e35a6afe 100644 --- a/modules/angular2/test/core/compiler/compiler_spec.ts +++ b/modules/angular2/test/core/compiler/compiler_spec.ts @@ -149,6 +149,26 @@ export function main() { }); })); + it('should not fill templateAbsUrl given template url with empty string', + inject([AsyncTestCompleter], (async) => { + cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js'); + captureTemplate(new ViewMetadata({template: null, templateUrl: ''})) + .then((renderTpl) => { + expect(renderTpl.templateAbsUrl).toBe(null); + async.done(); + }); + })); + + it('should not fill templateAbsUrl given template url with blank string', + inject([AsyncTestCompleter], (async) => { + cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js'); + captureTemplate(new ViewMetadata({template: null, templateUrl: ' '})) + .then((renderTpl) => { + expect(renderTpl.templateAbsUrl).toBe(null); + async.done(); + }); + })); + it('should fill templateAbsUrl given url template', inject([AsyncTestCompleter], (async) => { cmpUrlMapper.setComponentUrl(MainComponent, '/cmp/main.js'); captureTemplate(new ViewMetadata({templateUrl: 'tpl/main.html'}))