From 73b61f80ebf7db14f443cfe751405f67e2b9ca68 Mon Sep 17 00:00:00 2001 From: Sergey Aksyonov Date: Mon, 22 Dec 2014 14:40:22 +0200 Subject: [PATCH 1/2] Fixed angular directive for complex ng-repeat expressions --- ng-sortable.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ng-sortable.js b/ng-sortable.js index 12b9388..873e4e8 100644 --- a/ng-sortable.js +++ b/ng-sortable.js @@ -17,9 +17,10 @@ angular.module('ng-sortable', []) (node.nodeValue.indexOf('ngRepeat:') !== -1) ); })[0]; - ngRepeat = ngRepeat.nodeValue.match(/ngRepeat:\s*([^\s]+)\s+in\s+([^\s|]+)/); + ngRepeat = ngRepeat.nodeValue.match(/ngRepeat:\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s)/); - var itemExpr = $parse(ngRepeat[1]); + var lhs = ngRepeat[1].match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/); + var itemExpr = $parse(lhs[3] || lhs[1]); var itemsExpr = $parse(ngRepeat[2]); return { From 3ab736b570bd3e09e548e5c079315a698122e807 Mon Sep 17 00:00:00 2001 From: Sergey Aksyonov Date: Mon, 22 Dec 2014 16:45:50 +0200 Subject: [PATCH 2/2] Fixed expression regex --- ng-sortable.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ng-sortable.js b/ng-sortable.js index 873e4e8..a1d572e 100644 --- a/ng-sortable.js +++ b/ng-sortable.js @@ -17,10 +17,9 @@ angular.module('ng-sortable', []) (node.nodeValue.indexOf('ngRepeat:') !== -1) ); })[0]; - ngRepeat = ngRepeat.nodeValue.match(/ngRepeat:\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s)/); + ngRepeat = ngRepeat.nodeValue.match(/ngRepeat:\s*(?:\(.*?,\s*)?([^\s)]+)[\s)]+in\s+([^\s|]+)/); - var lhs = ngRepeat[1].match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/); - var itemExpr = $parse(lhs[3] || lhs[1]); + var itemExpr = $parse(ngRepeat[1]); var itemsExpr = $parse(ngRepeat[2]); return {