Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 6c52e41

Browse files
committed
fix(track by): fix "track by"
Eenhance regex functions to avoid failures with the "track by" feature Fixes #806 and #665
2 parents b1c4fdc + 457be42 commit 6c52e41

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/uiSelectMultipleDirective.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,13 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
105105
locals[$select.parserResult.itemName] = list[p];
106106
result = $select.parserResult.modelMapper(scope, locals);
107107
if($select.parserResult.trackByExp){
108-
var matches = /\.(.+)/.exec($select.parserResult.trackByExp);
109-
if(matches.length>0 && result[matches[1]] == value[matches[1]]){
110-
resultMultiple.unshift(list[p]);
111-
return true;
108+
var propsItemNameMatches = /(\w*)\./.exec($select.parserResult.trackByExp);
109+
var matches = /\.([^\s]+)/.exec($select.parserResult.trackByExp);
110+
if(propsItemNameMatches.length > 0 && propsItemNameMatches[1] == $select.parserResult.itemName){
111+
if(matches.length>0 && result[matches[1]] == value[matches[1]]){
112+
resultMultiple.unshift(list[p]);
113+
return true;
114+
}
112115
}
113116
}
114117
if (angular.equals(result,value)){

0 commit comments

Comments
 (0)