diff --git a/src/ng/directive/ngRepeat.js b/src/ng/directive/ngRepeat.js index 0a2673ffdb6b..15f86baa5883 100644 --- a/src/ng/directive/ngRepeat.js +++ b/src/ng/directive/ngRepeat.js @@ -203,7 +203,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) { $$tlb: true, link: function($scope, $element, $attr, ctrl, $transclude){ var expression = $attr.ngRepeat; - var match = expression.match(/^\s*(.+)\s+in\s+([\r\n\s\S]*?)\s*(\s+track\s+by\s+(.+)\s*)?$/), + var match = expression.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/), trackByExp, trackByExpGetter, trackByIdExpFn, trackByIdArrayFn, trackByIdObjFn, lhs, rhs, valueIdentifier, keyIdentifier, hashFnLocals = {$id: hashKey}; @@ -215,7 +215,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) { lhs = match[1]; rhs = match[2]; - trackByExp = match[4]; + trackByExp = match[3]; if (trackByExp) { trackByExpGetter = $parse(trackByExp); diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index 2d70d4a4d447..638f082c1474 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -177,22 +177,6 @@ describe('ngRepeat', function() { }); - it('should allow expressions over multiple lines', function() { - scope.isTrue = function() { - return true; - }; - element = $compile( - '')(scope); - scope.items = [{name: 'igor'}]; - scope.$digest(); - - expect(element.find('li').text()).toBe('igor'); - }); - - it('should track using provided function when a filter is present', function() { scope.newArray = function (items) { var newArray = []; @@ -354,6 +338,38 @@ describe('ngRepeat', function() { }); + it('should allow expressions over multiple lines', function() { + element = $compile( + '')(scope); + + scope.isTrue = function() {return true;}; + scope.items = [{name: 'igor'}, {name: 'misko'}]; + + scope.$digest(); + + expect(element.text()).toEqual('igor/misko/'); + }); + + + it('should strip white space characters correctly', function() { + element = $compile( + '')(scope); + + scope.items = [{name: 'igor'}, {name: 'misko'}]; + + scope.$digest(); + + expect(element.text()).toEqual('misko/'); + }); + + it('should not ngRepeat over parent properties', function() { var Class = function() {}; Class.prototype.abc = function() {};