Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 3be3a52

Browse files
committed
fix(compiler): trim whitespace from templates (effects toast, bottomSheet, etc)
1 parent 4ef7d38 commit 3be3a52

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/core/services/compiler/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function mdCompilerService($q, $http, $injector, $compile, $controller, $templat
102102
return $q.all(resolve).then(function(locals) {
103103

104104
var template = transformTemplate(locals.$template);
105-
var element = angular.element('<div>').html(template).contents();
105+
var element = angular.element('<div>').html(template.trim()).contents();
106106
var linkFn = $compile(element);
107107

108108
//Return a linking function that can be used later when the element is ready

src/core/services/compiler/compiler.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ describe('$mdCompiler service', function() {
3131
expect(data.element.html()).toBe(tpl);
3232
});
3333

34+
it('element should use template with whitespace', function() {
35+
var tpl = ' \nhello\n\t ';
36+
var data = compile({
37+
template: tpl
38+
});
39+
expect(data.element.html()).toBe('hello');
40+
});
41+
3442
it('transformTemplate should work with template', function() {
3543
var data = compile({
3644
template: 'world',

0 commit comments

Comments
 (0)