From f2106692b1ebf00aa5f8b2accd75f014b6cd4faa Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Wed, 28 Mar 2012 13:47:57 -0700 Subject: fix($compile): properly clone attr.$observers in ng-repeat The `attr` object was only shallow copied which caused all observers to be shared. Fixing similar issue in ng-* boolean attributes as well as ng-src and ng-href. --- test/ng/compilerSpec.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test') diff --git a/test/ng/compilerSpec.js b/test/ng/compilerSpec.js index dc2e20cf..fb5e99e6 100644 --- a/test/ng/compilerSpec.js +++ b/test/ng/compilerSpec.js @@ -1374,6 +1374,41 @@ describe('$compile', function() { }); + it('should properly $observe inside ng-repeat', function() { + var spies = []; + + module(function($compileProvider) { + $compileProvider.directive('observer', function() { + return function(scope, elm, attr) { + spies.push(jasmine.createSpy('observer ' + spies.length)); + attr.$observe('some', spies[spies.length - 1]); + }; + }); + }); + + inject(function($compile, $rootScope) { + element = $compile('