mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-15 10:13:10 +00:00
fix(ngRepeat): correct variable reference in error message
Closese #803
This commit is contained in:
parent
78a6291666
commit
935c1018da
2 changed files with 11 additions and 4 deletions
|
|
@ -73,10 +73,10 @@ var ngRepeatDirective = ngDirective({
|
||||||
}
|
}
|
||||||
lhs = match[1];
|
lhs = match[1];
|
||||||
rhs = match[2];
|
rhs = match[2];
|
||||||
match = lhs.match(/^([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\)$/);
|
match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
throw Error("'item' in 'item in collection' should be identifier or (key, value) but got '" +
|
throw Error("'item' in 'item in collection' should be identifier or (key, value) but got '" +
|
||||||
keyValue + "'.");
|
lhs + "'.");
|
||||||
}
|
}
|
||||||
valueIdent = match[3] || match[1];
|
valueIdent = match[3] || match[1];
|
||||||
keyIdent = match[2];
|
keyIdent = match[2];
|
||||||
|
|
|
||||||
|
|
@ -64,12 +64,19 @@ describe('ng-repeat', function() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should error on wrong parsing of ng-repeat', inject(function($rootScope, $compile, $log) {
|
it('should error on wrong parsing of ng-repeat', inject(function($rootScope, $compile) {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
element = $compile('<ul><li ng-repeat="i dont parse"></li></ul>')($rootScope);
|
element = $compile('<ul><li ng-repeat="i dont parse"></li></ul>')($rootScope);
|
||||||
}).toThrow("Expected ng-repeat in form of '_item_ in _collection_' but got 'i dont parse'.");
|
}).toThrow("Expected ng-repeat in form of '_item_ in _collection_' but got 'i dont parse'.");
|
||||||
|
}));
|
||||||
|
|
||||||
$log.error.logs.shift();
|
|
||||||
|
it("should throw error when left-hand-side of ng-repeat can't be parsed", inject(
|
||||||
|
function($rootScope, $compile) {
|
||||||
|
expect(function() {
|
||||||
|
element = $compile('<ul><li ng-repeat="i dont parse in foo"></li></ul>')($rootScope);
|
||||||
|
}).toThrow("'item' in 'item in collection' should be identifier or (key, value) but got " +
|
||||||
|
"'i dont parse'.");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue