From 6a8edc1d43aca7c5a92f86309b1bb1d5f9968442 Mon Sep 17 00:00:00 2001 From: jankuca Date: Wed, 25 Sep 2013 15:35:50 -0700 Subject: fix($compile): collect ranges on multiple directives on one element The problem was in keeping the values of `attrNameStart` and `attrNameEnd` between directive loop iterations which lead to the compiler looking for multi-element ranges for any directives that happened to be in the directive list after one that was applied on a range. For instance, having a ng-repeat-start and ng-class on a single element with ng-repeat being resolved first made the compiler look for an ng-repeat-end for both ng-repeat and ng-class because the `attrNameEnd` was not reset to a falsy value before the second iteration. As the result, an exception saying the block end element could not be found and the second directive was not actually applied. Closes #4002 --- test/ng/compileSpec.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test') diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index d2643878..2d6485d9 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -3382,6 +3382,38 @@ describe('$compile', function() { }); + it('should correctly collect ranges on multiple directives on a single element', function () { + module(function($compileProvider) { + $compileProvider.directive('emptyDirective', function() { + return function (scope, element) { + element.data('x', 'abc'); + }; + }); + $compileProvider.directive('rangeDirective', function() { + return { + link: function (scope) { + scope.x = 'X'; + scope.y = 'Y'; + } + }; + }); + }); + + inject(function ($compile, $rootScope) { + element = $compile( + '