From 20fd2b6f0d499f6ca7104b0fca9dc5a0c2ab9bf7 Mon Sep 17 00:00:00 2001 From: Sekib Omazic Date: Tue, 25 Mar 2014 13:24:06 +0100 Subject: [PATCH] fix(ngRepeat): allow extra whitespaces in (key,value) of ngRepeat Whitespaces allowed in (key,value) expression of ngRepeat. e.g. ( aaa , bbb ) will be accepted by parser closes #6827 --- src/ng/directive/ngRepeat.js | 2 +- test/ng/directive/ngRepeatSpec.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ng/directive/ngRepeat.js b/src/ng/directive/ngRepeat.js index 69192cc4a3fb..6cac08b6fb6a 100644 --- a/src/ng/directive/ngRepeat.js +++ b/src/ng/directive/ngRepeat.js @@ -257,7 +257,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) { var aliasAs = match[3]; var trackByExp = match[4]; - match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/); + match = lhs.match(/^(?:(\s*[\$\w]+)|\(\s*([\$\w]+)\s*,\s*([\$\w]+)\s*\))$/); if (!match) { throw ngRepeatMinErr('iidexp', "'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.", diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index 00e36be69a7f..f5cfdf6d3890 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -146,6 +146,16 @@ describe('ngRepeat', function() { expect(element.text()).toEqual('misko:swe|shyam:set|'); }); + it('should iterate over on object/map where (key,value) contains whitespaces', function() { + element = $compile( + '')(scope); + scope.items = {me:'swe', you:'set'}; + scope.$digest(); + expect(element.text()).toEqual('me:swe|you:set|'); + }); + it('should iterate over an object/map with identical values', function() { element = $compile( '