diff options
| author | Igor Minar | 2012-10-25 00:33:36 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-10-29 19:38:03 -0700 |
| commit | 4dbd8452eb93b700c8aaafb7efb97cc20a2c0ff0 (patch) | |
| tree | cde56d1c5d8f205b9ed8650bf4930aaf77b58d4e /test/ng/compileSpec.js | |
| parent | 45a8db9c0814549425542bdb301af9d4a2b50f47 (diff) | |
| download | angular.js-4dbd8452eb93b700c8aaafb7efb97cc20a2c0ff0.tar.bz2 | |
fix($compile): prevent double attr interpolation w/ templateUrl
This fixes the issue that caused two attr interpolation observers
to be registered for the same attribute as a result of isolate
scope definition with attr (@) property for this attribute.
Duplicate observers would then fight with each other updating the
model.
The issue occured only when this directive was used in a repeater
because that's when we clone the template node which caused the
two observers to point to two different sets of $attr instances.
Closes #1166, #836
Diffstat (limited to 'test/ng/compileSpec.js')
| -rw-r--r-- | test/ng/compileSpec.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index b5e4c450..75af0181 100644 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -1048,6 +1048,39 @@ describe('$compile', function() { expect($exceptionHandler.errors).toEqual([]); }); }); + + + it('should resume delayed compilation without duplicates when in a repeater', function() { + // this is a test for a regression + // scope creation, isolate watcher setup, controller instantiation, etc should happen + // only once even if we are dealing with delayed compilation of a node due to templateUrl + // and the template node is in a repeater + + var controllerSpy = jasmine.createSpy('controller'); + + module(function($compileProvider) { + $compileProvider.directive('delayed', valueFn({ + controller: controllerSpy, + templateUrl: 'delayed.html', + scope: { + title: '@' + } + })); + }); + + inject(function($templateCache, $compile, $rootScope) { + $rootScope.coolTitle = 'boom!'; + $templateCache.put('delayed.html', '<div>{{title}}</div>'); + element = $compile( + '<div><div ng-repeat="i in [1,2]"><div delayed title="{{coolTitle + i}}"></div>|</div></div>' + )($rootScope); + + $rootScope.$apply(); + + expect(controllerSpy.callCount).toBe(2); + expect(element.text()).toBe('boom!1|boom!2|'); + }); + }); }); |
