diff options
| author | Misko Hevery | 2013-11-05 15:50:53 -0800 |
|---|---|---|
| committer | Igor Minar | 2013-11-07 22:08:05 -0800 |
| commit | 97c7a4e3791d7cb05c3317cc5f0c49ab93810bf6 (patch) | |
| tree | 0708f7dd550334d8209f4d5bc59a565a676aecd6 /test | |
| parent | d0efd5eefcc0aaf167c766513e152b74dd31bafe (diff) | |
| download | angular.js-97c7a4e3791d7cb05c3317cc5f0c49ab93810bf6.tar.bz2 | |
fix($compile): replaced element has isolate scope
Diffstat (limited to 'test')
| -rwxr-xr-x | test/ng/compileSpec.js | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 2b6b235f..75c111d7 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -2450,7 +2450,7 @@ describe('$compile', function() { it('should require controller of an isolate directive from a non-isolate directive on the ' + - 'same element', function() { + 'same element', function() { var IsolateController = function() {}; var isolateDirControllerInNonIsolateDirective; @@ -2480,6 +2480,79 @@ describe('$compile', function() { }); + it('should share isolate scope with replaced directives', function() { + var normalScope; + var isolateScope; + + module(function() { + directive('isolate', function() { + return { + replace: true, + scope: {}, + template: '<span ng-init="name=\'WORKS\'">{{name}}</span>', + link: function(s) { + isolateScope = s; + } + }; + }); + directive('nonIsolate', function() { + return { + link: function(s) { + normalScope = s; + } + }; + }); + }); + + inject(function($compile, $rootScope) { + element = $compile('<div isolate non-isolate></div>')($rootScope); + + expect(normalScope).toBe($rootScope); + expect(normalScope.name).toEqual(undefined); + expect(isolateScope.name).toEqual('WORKS'); + $rootScope.$digest(); + expect(element.text()).toEqual('WORKS'); + }); + }); + + + it('should share isolate scope with replaced directives', function() { + var normalScope; + var isolateScope; + + module(function() { + directive('isolate', function() { + return { + replace: true, + scope: {}, + templateUrl: 'main.html', + link: function(s) { + isolateScope = s; + } + }; + }); + directive('nonIsolate', function() { + return { + link: function(s) { + normalScope = s; + } + }; + }); + }); + + inject(function($compile, $rootScope, $templateCache) { + $templateCache.put('main.html', '<span ng-init="name=\'WORKS\'">{{name}}</span>'); + element = $compile('<div isolate non-isolate></div>')($rootScope); + $rootScope.$apply(); + + expect(normalScope).toBe($rootScope); + expect(normalScope.name).toEqual(undefined); + expect(isolateScope.name).toEqual('WORKS'); + expect(element.text()).toEqual('WORKS'); + }); + }); + + it('should require controller of a non-isolate directive from an isolate directive on the ' + 'same element', function() { var NonIsolateController = function() {}; |
