diff options
| author | Igor Minar | 2013-11-07 16:18:06 -0800 | 
|---|---|---|
| committer | Igor Minar | 2013-11-07 22:08:05 -0800 | 
| commit | b5af198f0d5b0f2b3ddb31ea12f700f3e0616271 (patch) | |
| tree | 0b199a02d5874083c6680de736a86a300f4e9987 /test/ng/compileSpec.js | |
| parent | 3fe4491a6bf57ddeb312b8a30cf1706f6f1d2355 (diff) | |
| download | angular.js-b5af198f0d5b0f2b3ddb31ea12f700f3e0616271.tar.bz2 | |
fix($compile): don't leak isolate scope state when replaced directive is used multiple times
When an isolate scope directive is also a "replace" directive and at the root of its template
it has other directives, we need to keep track remember to use isolate scope when linking
these.
This commit fixes the leakage of this state when this directive is used again later inside
or outside of the isolate directive template.
Diffstat (limited to 'test/ng/compileSpec.js')
| -rwxr-xr-x | test/ng/compileSpec.js | 39 | 
1 files changed, 37 insertions, 2 deletions
| diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 356b1796..a61d50f2 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -2504,7 +2504,7 @@ describe('$compile', function() {      }); -    it('should share isolate scope with replaced directives', function() { +    it('should share isolate scope with replaced directives (template)', function() {        var normalScope;        var isolateScope; @@ -2540,7 +2540,7 @@ describe('$compile', function() {      }); -    it('should share isolate scope with replaced directives', function() { +    it('should share isolate scope with replaced directives (templateUrl)', function() {        var normalScope;        var isolateScope; @@ -2577,6 +2577,41 @@ describe('$compile', function() {      }); +    it('should not get confused about where to use isolate scope when a replaced directive is used multiple times', +        function() { + +      module(function() { +        directive('isolate', function() { +          return { +            replace: true, +            scope: {}, +            template: '<span scope-tester="replaced"><span scope-tester="inside"></span></span>' +          }; +        }); +        directive('scopeTester', function(log) { +          return { +            link: function($scope, $element) { +              log($element.attr('scope-tester') + '=' + ($scope.$root === $scope ? 'non-isolate' : 'isolate')); +            } +          } +        }); +      }); + +      inject(function($compile, $rootScope, log) { +        element = $compile('<div>' + +                             '<div isolate scope-tester="outside"></div>' + +                             '<span scope-tester="sibling"></span>' + +                           '</div>')($rootScope); + +        $rootScope.$digest(); +        expect(log).toEqual('inside=isolate; ' + +                            'outside replaced=non-isolate; ' + // outside +                            'outside replaced=isolate; ' + // replaced +                            'sibling=non-isolate') +      }); +    }); + +      it('should require controller of a non-isolate directive from an isolate directive on the ' +         'same element', function() {        var NonIsolateController = function() {}; | 
