Skip to content

Commit

Permalink
fix(upgrade): allow directives with empty template
Browse files Browse the repository at this point in the history
  • Loading branch information
alex94cp authored and vsavkin committed Dec 11, 2015
1 parent b8e69a2 commit 2ca5e38
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/angular2/src/upgrade/upgrade_ng1_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class UpgradeNg1ComponentAdapterBuilder {

compileTemplate(compile: angular.ICompileService, templateCache: angular.ITemplateCacheService,
httpBackend: angular.IHttpBackendService): Promise<any> {
if (this.directive.template) {
if (this.directive.template !== undefined) {
this.linkFn = compileHtml(this.directive.template);
} else if (this.directive.templateUrl) {
var url = this.directive.templateUrl;
Expand Down
21 changes: 21 additions & 0 deletions modules/angular2/test/upgrade/upgrade_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,27 @@ export function main() {
});
}));

it('should support empty template', inject([AsyncTestCompleter], (async) => {
var adapter = new UpgradeAdapter();
var ng1Module = angular.module('ng1', []);

var ng1 = function() { return {template: ''}; };
ng1Module.directive('ng1', ng1);
var Ng2 = Component({
selector: 'ng2',
template: '<ng1></ng1>',
directives: [adapter.upgradeNg1Component('ng1')]
}).Class({constructor: function() {}});
ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2));
var element = html(`<div><ng2></ng2></div>`);
adapter.bootstrap(element, ['ng1'])
.ready((ref) => {
expect(multiTrim(document.body.textContent)).toEqual('');
ref.dispose();
async.done();
});
}));

it('should support templateUrl fetched from $templateCache',
inject([AsyncTestCompleter], (async) => {
var adapter = new UpgradeAdapter();
Expand Down

0 comments on commit 2ca5e38

Please sign in to comment.