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

Commit 935c101

Browse files
committed
fix(ngRepeat): correct variable reference in error message
Closese #803
1 parent 78a6291 commit 935c101

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/directive/ngRepeat.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ var ngRepeatDirective = ngDirective({
7373
}
7474
lhs = match[1];
7575
rhs = match[2];
76-
match = lhs.match(/^([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\)$/);
76+
match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);
7777
if (!match) {
7878
throw Error("'item' in 'item in collection' should be identifier or (key, value) but got '" +
79-
keyValue + "'.");
79+
lhs + "'.");
8080
}
8181
valueIdent = match[3] || match[1];
8282
keyIdent = match[2];

test/directive/ngRepeatSpec.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,19 @@ describe('ng-repeat', function() {
6464
}));
6565

6666

67-
it('should error on wrong parsing of ng-repeat', inject(function($rootScope, $compile, $log) {
67+
it('should error on wrong parsing of ng-repeat', inject(function($rootScope, $compile) {
6868
expect(function() {
6969
element = $compile('<ul><li ng-repeat="i dont parse"></li></ul>')($rootScope);
7070
}).toThrow("Expected ng-repeat in form of '_item_ in _collection_' but got 'i dont parse'.");
71+
}));
72+
7173

72-
$log.error.logs.shift();
74+
it("should throw error when left-hand-side of ng-repeat can't be parsed", inject(
75+
function($rootScope, $compile) {
76+
expect(function() {
77+
element = $compile('<ul><li ng-repeat="i dont parse in foo"></li></ul>')($rootScope);
78+
}).toThrow("'item' in 'item in collection' should be identifier or (key, value) but got " +
79+
"'i dont parse'.");
7380
}));
7481

7582

0 commit comments

Comments
 (0)