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

Commit 833eb3c

Browse files
committed
fix(ng:repeat): repeater should ignore $ and $$ properties
1 parent 07926ff commit 833eb3c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/widgets.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ angularWidget('@ng:repeat', function(expression, element){
373373
cursor = iterStartElement; // current position of the node
374374

375375
for (key in collection) {
376-
if (collection.hasOwnProperty(key)) {
376+
if (collection.hasOwnProperty(key) && key.charAt(0) != '$') {
377377
last = lastOrder.shift(value = collection[key]);
378378
if (last) {
379379
// if we have already seen this object, then we need to reuse the

test/widgetsSpec.js

+22
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,28 @@ describe("widget", function() {
290290
expect(element.text()).toEqual('misko:m:first|shyam:s:last|');
291291
});
292292

293+
it('should ignore $ and $$ properties', function() {
294+
var scope = compile('<ul><li ng:repeat="i in items">{{i}}|</li></ul>');
295+
scope.items = ['a', 'b', 'c'];
296+
scope.items.$$hashkey = 'xxx';
297+
scope.items.$root = 'yyy';
298+
scope.$digest();
299+
300+
expect(element.text()).toEqual('a|b|c|');
301+
});
302+
303+
it('should repeat over nested arrays', function() {
304+
var scope = compile('<ul>' +
305+
'<li ng:repeat="subgroup in groups">' +
306+
'<div ng:repeat="group in subgroup">{{group}}|</div>X' +
307+
'</li>' +
308+
'</ul>');
309+
scope.groups = [['a', 'b'], ['c','d']];
310+
scope.$digest();
311+
312+
expect(element.text()).toEqual('a|b|Xc|d|X');
313+
});
314+
293315

294316
describe('stability', function() {
295317
var a, b, c, d, scope, lis;

0 commit comments

Comments
 (0)