Skip to content

Commit

Permalink
fix(compiler): detect and report error for views with empty templateUrl
Browse files Browse the repository at this point in the history
Fixes #3762

Closes #3768
  • Loading branch information
pkozlowski-opensource committed Aug 23, 2015
1 parent 3871f89 commit 215c4aa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/angular2/src/core/compiler/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions modules/angular2/test/core/compiler/compiler_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'}))
Expand Down

0 comments on commit 215c4aa

Please sign in to comment.