From 909cabd36d779598763cc358979ecd85bb40d4d7 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Tue, 5 Nov 2013 12:31:20 -0800 Subject: fix($compile): make isolate scope truly isolate Fixes issue with isolate scope leaking all over the place into other directives on the same element. Isolate scope is now available only to the isolate directive that requested it and its template. A non-isolate directive should not get the isolate scope of an isolate directive on the same element, instead they will receive the original scope (which is the parent scope of the newly created isolate scope). Paired with Tobias. BREAKING CHANGE: Directives without isolate scope do not get the isolate scope from an isolate directive on the same element. If your code depends on this behavior (non-isolate directive needs to access state from within the isolate scope), change the isolate directive to use scope locals to pass these explicitly. // before .directive('ngIsolate', function() { return { scope: {}, template: '{{value}}' }; }); // after .directive('ngIsolate', function() { return { scope: {value: '=ngModel'}, template: '{{value}} }; }); Closes #1924 Closes #2500 --- test/ng/compileSpec.js | 87 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index c6cba3a4..09048885 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -1375,7 +1375,7 @@ describe('$compile', function() { return function (scope, element) { iscope = scope; log(scope.$id); - expect(element.data('$scope')).toBe(scope); + expect(element.data('$isolateScope')).toBe(scope); }; } }; @@ -1416,7 +1416,7 @@ describe('$compile', function() { return function (scope, element) { iscope = scope; log(scope.$id); - expect(element.data('$scope')).toBe(scope); + expect(element.data('$isolateScope')).toBe(scope); }; } }; @@ -1535,7 +1535,7 @@ describe('$compile', function() { expect(function(){ $compile('
'); }).toThrowMinErr('$compile', 'multidir', 'Multiple directives [iscopeA, scopeB] asking for new/isolated scope on: ' + - '