@@ -153,7 +153,7 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) {
153
153
var animate = $animator ( $scope , $attr ) ;
154
154
var expression = $attr . ngRepeat ;
155
155
var match = expression . match ( / ^ \s * ( .+ ) \s + i n \s + ( .* ?) \s * ( \s + t r a c k \s + b y \s + ( .+ ) \s * ) ? $ / ) ,
156
- trackByExp , hashExpFn , trackByIdFn , lhs , rhs , valueIdentifier , keyIdentifier ,
156
+ trackByExp , trackByExpGetter , trackByIdFn , lhs , rhs , valueIdentifier , keyIdentifier ,
157
157
hashFnLocals = { $id : hashKey } ;
158
158
159
159
if ( ! match ) {
@@ -166,13 +166,13 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) {
166
166
trackByExp = match [ 4 ] ;
167
167
168
168
if ( trackByExp ) {
169
- hashExpFn = $parse ( trackByExp ) ;
169
+ trackByExpGetter = $parse ( trackByExp ) ;
170
170
trackByIdFn = function ( key , value , index ) {
171
171
// assign key, value, and $index to the locals so that they can be used in hash functions
172
172
if ( keyIdentifier ) hashFnLocals [ keyIdentifier ] = key ;
173
173
hashFnLocals [ valueIdentifier ] = value ;
174
174
hashFnLocals . $index = index ;
175
- return hashExpFn ( $scope , hashFnLocals ) ;
175
+ return trackByExpGetter ( $scope , hashFnLocals ) ;
176
176
} ;
177
177
} else {
178
178
trackByIdFn = function ( key , value ) {
@@ -233,7 +233,8 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) {
233
233
key = ( collection === collectionKeys ) ? index : collectionKeys [ index ] ;
234
234
value = collection [ key ] ;
235
235
trackById = trackByIdFn ( key , value , index ) ;
236
- if ( ( block = lastBlockMap [ trackById ] ) ) {
236
+ if ( lastBlockMap . hasOwnProperty ( trackById ) ) {
237
+ block = lastBlockMap [ trackById ]
237
238
delete lastBlockMap [ trackById ] ;
238
239
nextBlockMap [ trackById ] = block ;
239
240
nextBlockOrder [ index ] = block ;
@@ -243,10 +244,12 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) {
243
244
if ( block && block . element ) lastBlockMap [ block . id ] = block ;
244
245
} ) ;
245
246
// This is a duplicate and we need to throw an error
246
- throw new Error ( 'Duplicates in a repeater are not allowed. Repeater: ' + expression ) ;
247
+ throw new Error ( 'Duplicates in a repeater are not allowed. Repeater: ' + expression +
248
+ ' key: ' + trackById ) ;
247
249
} else {
248
250
// new never before seen block
249
251
nextBlockOrder [ index ] = { id : trackById } ;
252
+ nextBlockMap [ trackById ] = false ;
250
253
}
251
254
}
252
255
0 commit comments