Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(ng:repeat): repeater should ignore $ and $$ properties
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMinar committed Oct 19, 2011
1 parent 07926ff commit 833eb3c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions test/widgetsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 833eb3c

Please sign in to comment.