');
});
});
@@ -1205,7 +1207,7 @@ describe('$compile', function() {
));
- it('should work when directive is a repeater', inject(
+ it('should work when directive is in a repeater', inject(
function($compile, $httpBackend, $rootScope) {
$httpBackend.expect('GET', 'hello.html').
respond('
i=;');
@@ -1317,7 +1319,7 @@ describe('$compile', function() {
});
- describe('template as function', function() {
+ describe('templateUrl as function', function() {
beforeEach(module(function() {
directive('myDirective', valueFn({
@@ -2745,23 +2747,81 @@ describe('$compile', function() {
});
- it('should only allow one transclude per element', function() {
+ it('should only allow one content transclusion per element', function() {
module(function() {
directive('first', valueFn({
- scope: {},
- restrict: 'CA',
- transclude: 'content'
+ transclude: true
}));
directive('second', valueFn({
- restrict: 'CA',
- transclude: 'content'
+ transclude: true
}));
});
inject(function($compile) {
expect(function() {
- $compile('
');
+ $compile('
');
+ }).toThrowMinErr('$compile', 'multidir', /Multiple directives \[first, second\] asking for transclusion on:
');
}).toThrowMinErr('$compile', 'multidir', 'Multiple directives [first, second] asking for transclusion on: ' +
- '
');
+ '');
+ });
+ });
+
+
+ it('should only allow one element transclusion per element when directives have different priorities', function() {
+ // we restart compilation in this case and we need to remember the duplicates during the second compile
+ // regression #3893
+ module(function() {
+ directive('first', valueFn({
+ transclude: 'element',
+ priority: 100
+ }));
+ directive('second', valueFn({
+ transclude: 'element'
+ }));
+ });
+ inject(function($compile) {
+ expect(function() {
+ $compile('
');
+ }).toThrowMinErr('$compile', 'multidir', /Multiple directives \[first, second\] asking for transclusion on:
template.html');
+ $compile('
');
+ expect(function() {
+ $httpBackend.flush();
+ }).toThrowMinErr('$compile', 'multidir', /Multiple directives \[first, second\] asking for transclusion on:
{{i}}
')($rootScope);
+ $rootScope.$digest();
+ expect(element.text()).toBe('[[1]][[2]]')
+ });
+ });
+
+
+ it('should allow mixing ngRepeat with ngInclude', inject(function($compile, $rootScope, $httpBackend) {
+ $httpBackend.whenGET('someTemplate.html').respond('
some template;
');
+ element = $compile('
')($rootScope);
+ $rootScope.$digest();
+ $httpBackend.flush();
+ expect(element.text()).toBe('some template; some template; ');
+ }));
+
+
+ it('should allow mixing ngRepeat with ngIf', inject(function($compile, $rootScope) {
+ element = $compile('
')($rootScope);
+ $rootScope.$digest();
+ expect(element.text()).toBe('2;4;');
+ }));
+ });
+
+
describe('ngRepeatStart', function () {
it('should grow multi-node repeater', inject(function($compile, $rootScope) {
$rootScope.show = false;