aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/directive
diff options
context:
space:
mode:
authorIgor Minar2013-10-10 21:35:54 -0700
committerIgor Minar2013-10-11 17:12:24 -0700
commit63c5334c84b7269428c710226764d1f08a36e0d4 (patch)
tree4924c3e942b6d94d7dcc9bfb6ab629fd52491a0f /test/ng/directive
parentb7af76b4c5aa77648cc1bfd49935b48583419023 (diff)
downloadangular.js-63c5334c84b7269428c710226764d1f08a36e0d4.tar.bz2
fix($compile): abort compilation when duplicate element transclusion
Issue an error and abort compilation when two directives that ask for transclusion are found on a single element. This configuration is not supported and we previously failed to issue the error because in the case of element transclusion the compilation is re-started and this caused the compilation context to be lost. The ngRepeat directive has been special-cased to bypass this warning because it knows how to handle this scenario internally. This is not an ideal solution to the problem of multiple transclusions per element, we are hoping to have this configuration supported by the compiler in the future. See #4357. Closes #3893 Closes #4217 Closes #3307
Diffstat (limited to 'test/ng/directive')
-rw-r--r--test/ng/directive/ngRepeatSpec.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js
index 8dba13bf..9dde36e7 100644
--- a/test/ng/directive/ngRepeatSpec.js
+++ b/test/ng/directive/ngRepeatSpec.js
@@ -976,6 +976,43 @@ describe('ngRepeat', function() {
});
+ describe('compatibility', function() {
+
+ it('should allow mixing ngRepeat and another element transclusion directive', function() {
+ $compileProvider.directive('elmTrans', valueFn({
+ transclude: 'element',
+ controller: function($transclude, $scope, $element) {
+ $transclude(function(transcludedNodes) {
+ $element.after(']]').after(transcludedNodes).after('[[');
+ });
+ }
+ }));
+
+ inject(function($compile, $rootScope) {
+ element = $compile('<div><div ng-repeat="i in [1,2]" elm-trans>{{i}}</div></div>')($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('<p>some template; </p>');
+ element = $compile('<div><div ng-repeat="i in [1,2]" ng-include="\'someTemplate.html\'"></div></div>')($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('<div><div ng-repeat="i in [1,2,3,4]" ng-if="i % 2 == 0">{{i}};</div></div>')($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;