aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/directive
diff options
context:
space:
mode:
authorjankuca2013-09-24 13:51:28 -0700
committerIgor Minar2013-09-25 09:42:01 -0700
commit31c56f540045b5270f5b8e235873da855caf3486 (patch)
tree6a1fd7c9849122dabe71154c28bde4f7b9a91fc0 /test/ng/directive
parentf8f8f754b02459bb789247476cc0da63d2d7370f (diff)
downloadangular.js-31c56f540045b5270f5b8e235873da855caf3486.tar.bz2
fix(ngRepeat): correctly track elements even when the collection is initially undefined
Previously if the collection model was set to undefined on the first digest, the repeater would get confused and not use the correct tracking function for associating model with dom elements in the repeater. Closes #4145 Closes #3964
Diffstat (limited to 'test/ng/directive')
-rw-r--r--test/ng/directive/ngRepeatSpec.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js
index fc41bc6d..72035566 100644
--- a/test/ng/directive/ngRepeatSpec.js
+++ b/test/ng/directive/ngRepeatSpec.js
@@ -841,6 +841,26 @@ describe('ngRepeat', function() {
expect(newLis[1]).toEqual(lis[0]);
expect(newLis[2]).toEqual(lis[1]);
});
+
+ it('should be stable even if the collection is initially undefined', function () {
+ scope.items = undefined;
+ scope.$digest();
+
+ scope.items = [
+ { name: 'A' },
+ { name: 'B' },
+ { name: 'C' }
+ ];
+ scope.$digest();
+
+ lis = element.find('li');
+ scope.items.shift();
+ scope.$digest();
+
+ var newLis = element.find('li');
+ expect(newLis.length).toBe(2);
+ expect(newLis[0]).toBe(lis[1]);
+ });
});
it('should grow multi-node repeater', inject(function($compile, $rootScope) {
@@ -861,8 +881,6 @@ describe('ngRepeat', function() {
$rootScope.$digest();
expect(element.text()).toEqual('T1:D1;T2:D2;T3:D3;');
}));
-
-
});
describe('ngRepeat animations', function() {