From d0efd5eefcc0aaf167c766513e152b74dd31bafe Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Tue, 5 Nov 2013 12:27:56 -0800 Subject: fix($compile): only pass isolate scope to children that belong to the isolate directive I had to fix one unit test, as it assumed the broken behavior, where application template gets the isolate scope of other (isolate) directive, rather than the regular scope. BREAKING CHANGE: Child elements that are defined either in the application template or in some other directives template do not get the isolate scope. In theory, nobody should rely on this behavior, as it is very rare - in most cases the isolate directive has a template. --- test/ng/compileSpec.js | 60 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 09048885..2b6b235f 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -1426,7 +1426,7 @@ describe('$compile', function() { return { restrict: 'CA', link: {pre: function(scope) { - log('log-' + scope.$id + '-' + scope.$parent.$id); + log('log-' + scope.$id + '-' + (scope.$parent && scope.$parent.$id || 'no-parent')); }} }; }); @@ -1443,7 +1443,7 @@ describe('$compile', function() { it('should allow creation of new isolated scopes for directives', inject( function($rootScope, $compile, log) { element = $compile('
')($rootScope); - expect(log).toEqual('log-002-001; LOG; 002'); + expect(log).toEqual('log-001-no-parent; LOG; 002'); $rootScope.name = 'abc'; expect(iscope.$parent).toBe($rootScope); expect(iscope.name).toBeUndefined(); @@ -2131,6 +2131,62 @@ describe('$compile', function() { expect(componentScope.$parent).toBe(regularScope) })); + it('should not give the isolate scope to other directive template', function() { + module(function() { + directive('otherTplDir', function() { + return { + template: 'value: {{value}}' + }; + }); + }); + + inject(function($rootScope) { + compile('