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

Commit ef640cb

Browse files
SekibOmazicpkozlowski-opensource
authored andcommitted
fix(ngRepeat): allow extra whitespaces in (key,value) part of micro-syntax
e.g. ( aaa , bbb ) will be accepted by parser Fixes #6827 Closes #6833
1 parent 081fef6 commit ef640cb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/ng/directive/ngRepeat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
257257
var aliasAs = match[3];
258258
var trackByExp = match[4];
259259

260-
match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);
260+
match = lhs.match(/^(?:(\s*[\$\w]+)|\(\s*([\$\w]+)\s*,\s*([\$\w]+)\s*\))$/);
261261

262262
if (!match) {
263263
throw ngRepeatMinErr('iidexp', "'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.",

test/ng/directive/ngRepeatSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ describe('ngRepeat', function() {
146146
expect(element.text()).toEqual('misko:swe|shyam:set|');
147147
});
148148

149+
it('should iterate over on object/map where (key,value) contains whitespaces', function() {
150+
element = $compile(
151+
'<ul>' +
152+
'<li ng-repeat="( key , value ) in items">{{key}}:{{value}}|</li>' +
153+
'</ul>')(scope);
154+
scope.items = {me:'swe', you:'set'};
155+
scope.$digest();
156+
expect(element.text()).toEqual('me:swe|you:set|');
157+
});
158+
149159
it('should iterate over an object/map with identical values', function() {
150160
element = $compile(
151161
'<ul>' +

0 commit comments

Comments
 (0)