From 3d625463149d059c0e434bb8796b5193b56ae7b4 Mon Sep 17 00:00:00 2001 From: Matthew Hill Date: Sun, 12 Apr 2015 18:03:01 +0100 Subject: [PATCH] fix(compiler): only sets viewDefinition absUrl if the view has either a template or templateUrl fixes #1326 closes #1327 --- modules/angular2/src/core/compiler/compiler.js | 2 +- modules/angular2/test/core/compiler/compiler_spec.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/core/compiler/compiler.js b/modules/angular2/src/core/compiler/compiler.js index 06f53b040c..a27f334730 100644 --- a/modules/angular2/src/core/compiler/compiler.js +++ b/modules/angular2/src/core/compiler/compiler.js @@ -205,7 +205,7 @@ export class Compiler { var templateAbsUrl = null; if (isPresent(view.templateUrl)) { templateAbsUrl = this._urlResolver.resolve(componentUrl, view.templateUrl); - } else { + } else if (isPresent(view.template)) { // Note: If we have an inline template, we also need to send // the url for the component to the renderer so that it // is able to resolve urls in stylesheets. diff --git a/modules/angular2/test/core/compiler/compiler_spec.js b/modules/angular2/test/core/compiler/compiler_spec.js index 6ca3d46ae4..cad4a8b552 100644 --- a/modules/angular2/test/core/compiler/compiler_spec.js +++ b/modules/angular2/test/core/compiler/compiler_spec.js @@ -105,6 +105,14 @@ export function main() { }); })); + it('should not fill absUrl given no inline template or template url', inject([AsyncTestCompleter], (async) => { + cmpUrlMapper.setComponentUrl(MainComponent, '/mainComponent'); + captureTemplate(new View({template: null, templateUrl: null})).then( (renderTpl) => { + expect(renderTpl.absUrl).toBe(null) + async.done(); + }); + })); + it('should fill absUrl given url template', inject([AsyncTestCompleter], (async) => { cmpUrlMapper.setComponentUrl(MainComponent, '/mainComponent'); captureTemplate(new View({templateUrl: '/someTemplate'})).then( (renderTpl) => {