fix(ng:repeat): repeater should ignore $ and $$ properties

This commit is contained in:
Igor Minar 2011-10-18 16:46:27 -07:00
parent 07926ff1ef
commit 833eb3c844
2 changed files with 23 additions and 1 deletions

View file

@ -373,7 +373,7 @@ angularWidget('@ng:repeat', function(expression, element){
cursor = iterStartElement; // current position of the node
for (key in collection) {
if (collection.hasOwnProperty(key)) {
if (collection.hasOwnProperty(key) && key.charAt(0) != '$') {
last = lastOrder.shift(value = collection[key]);
if (last) {
// if we have already seen this object, then we need to reuse the

View file

@ -290,6 +290,28 @@ describe("widget", function() {
expect(element.text()).toEqual('misko:m:first|shyam:s:last|');
});
it('should ignore $ and $$ properties', function() {
var scope = compile('<ul><li ng:repeat="i in items">{{i}}|</li></ul>');
scope.items = ['a', 'b', 'c'];
scope.items.$$hashkey = 'xxx';
scope.items.$root = 'yyy';
scope.$digest();
expect(element.text()).toEqual('a|b|c|');
});
it('should repeat over nested arrays', function() {
var scope = compile('<ul>' +
'<li ng:repeat="subgroup in groups">' +
'<div ng:repeat="group in subgroup">{{group}}|</div>X' +
'</li>' +
'</ul>');
scope.groups = [['a', 'b'], ['c','d']];
scope.$digest();
expect(element.text()).toEqual('a|b|Xc|d|X');
});
describe('stability', function() {
var a, b, c, d, scope, lis;