From 40640aa8db32a204318e27e680f5ead7391a8859 Mon Sep 17 00:00:00 2001 From: Rhys Brett-bowen Date: Mon, 18 Nov 2013 10:02:55 -0500 Subject: [PATCH 1/2] feat(ngRepeat): allow multiple line expressions allow new line characters when checking the expression and pass through to regular parser. --- src/ng/directive/ngRepeat.js | 2 +- test/ng/directive/ngRepeatSpec.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ng/directive/ngRepeat.js b/src/ng/directive/ngRepeat.js index a5614bf451fa..d5ada53216a6 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+(.*?)\s*(\s+track\s+by\s+(.+)\s*)?$/), + var match = expression.match(/^\s*(.+)\s+in\s+((?:[\r\n]*.*)*?)\s*(\s+track\s+by\s+(.+)\s*)?$/), trackByExp, trackByExpGetter, trackByIdExpFn, trackByIdArrayFn, trackByIdObjFn, lhs, rhs, valueIdentifier, keyIdentifier, hashFnLocals = {$id: hashKey}; diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index 6584f31addd8..3ac918a64d1f 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -177,6 +177,22 @@ 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 = []; From b644b2fc2cb5434b2acea66befa2161c28dcc6e2 Mon Sep 17 00:00:00 2001 From: rhysbrettbowen Date: Mon, 18 Nov 2013 10:31:34 -0500 Subject: [PATCH 2/2] feat(ngRepeat): allow multiple line expressions allow and pass through new line characters when checking passed in expression --- src/ng/directive/ngRepeat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/directive/ngRepeat.js b/src/ng/directive/ngRepeat.js index d5ada53216a6..b92f5a5b55a7 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+track\s+by\s+(.+)\s*)?$/), + var match = expression.match(/^\s*(.+)\s+in\s+([\r\n\s\S]*?)\s*(\s+track\s+by\s+(.+)\s*)?$/), trackByExp, trackByExpGetter, trackByIdExpFn, trackByIdArrayFn, trackByIdObjFn, lhs, rhs, valueIdentifier, keyIdentifier, hashFnLocals = {$id: hashKey};