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

Commit 32886b1

Browse files
author
Prashant Pawar
committed
Merge branch 'bugfix/15108-directive-template-with-space' of github.com:prashantpawar/angular.js into bugfix/15108-directive-template-with-space
2 parents b1dc249 + 17cf76f commit 32886b1

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/ng/compileSpec.js

+36
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,22 @@ describe('$compile', function() {
13641364
});
13651365
});
13661366

1367+
it('should ignore whitespace betwee comment and root node when replacing with a template', function() {
1368+
module(function() {
1369+
directive('replaceWithWhitespace', valueFn({
1370+
replace: true,
1371+
template: '<!-- ignored comment --> <p>Hello, world!</p> <!-- ignored comment-->'
1372+
}));
1373+
});
1374+
inject(function($compile, $rootScope) {
1375+
expect(function() {
1376+
element = $compile('<div><div replace-with-whitespace></div></div>')($rootScope);
1377+
}).not.toThrow();
1378+
expect(element.find('p').length).toBe(1);
1379+
expect(element.find('p').text()).toBe('Hello, world!');
1380+
});
1381+
});
1382+
13671383
it('should keep prototype properties on directive', function() {
13681384
module(function() {
13691385
function DirectiveClass() {
@@ -2303,6 +2319,26 @@ describe('$compile', function() {
23032319
});
23042320
});
23052321

2322+
it('should ignore whitespace between comment and root node when replacing with a templateUrl', function() {
2323+
module(function() {
2324+
directive('replaceWithWhitespace', valueFn({
2325+
replace: true,
2326+
templateUrl: 'templateWithWhitespace.html'
2327+
}));
2328+
});
2329+
inject(function($compile, $rootScope, $httpBackend) {
2330+
$httpBackend.whenGET('templateWithWhitespace.html').
2331+
respond('<!-- ignored comment --> <p>Hello, world!</p> <!-- ignored comment-->');
2332+
expect(function() {
2333+
element = $compile('<div><div replace-with-whitespace></div></div>')($rootScope);
2334+
}).not.toThrow();
2335+
$httpBackend.flush();
2336+
expect(element.find('p').length).toBe(1);
2337+
expect(element.find('p').text()).toBe('Hello, world!');
2338+
});
2339+
});
2340+
2341+
23062342
it('should keep prototype properties on sync version of async directive', function() {
23072343
module(function() {
23082344
function DirectiveClass() {

0 commit comments

Comments
 (0)