@@ -225,6 +225,14 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
225
225
// jshint bitwise: true
226
226
} ;
227
227
228
+ var getBlockStart = function ( block ) {
229
+ return block . clone [ 0 ] ;
230
+ } ;
231
+
232
+ var getBlockEnd = function ( block ) {
233
+ return block . clone [ block . clone . length - 1 ] ;
234
+ } ;
235
+
228
236
229
237
return {
230
238
restrict : 'A' ,
@@ -292,7 +300,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
292
300
var lastBlockMap = { } ;
293
301
294
302
//watch props
295
- $scope . $watchCollection ( rhs , function ngRepeatAction ( collection ) {
303
+ $scope . $watchCollection ( rhs , function ngRepeatAction ( collection ) {
296
304
var index , length ,
297
305
previousNode = $element [ 0 ] , // current position of the node
298
306
nextNode ,
@@ -343,15 +351,15 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
343
351
nextBlockOrder [ index ] = block ;
344
352
} else if ( nextBlockMap . hasOwnProperty ( trackById ) ) {
345
353
// restore lastBlockMap
346
- forEach ( nextBlockOrder , function ( block ) {
354
+ forEach ( nextBlockOrder , function ( block ) {
347
355
if ( block && block . scope ) lastBlockMap [ block . id ] = block ;
348
356
} ) ;
349
357
// This is a duplicate and we need to throw an error
350
358
throw ngRepeatMinErr ( 'dupes' , "Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: {0}, Duplicate key: {1}" ,
351
- expression , trackById ) ;
359
+ expression , trackById ) ;
352
360
} else {
353
361
// new never before seen block
354
- nextBlockOrder [ index ] = { id : trackById , scope : undefined , clone : undefined } ;
362
+ nextBlockOrder [ index ] = { id : trackById , scope : undefined , clone : undefined } ;
355
363
nextBlockMap [ trackById ] = false ;
356
364
}
357
365
}
@@ -363,7 +371,9 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
363
371
block = lastBlockMap [ blockKey ] ;
364
372
elementsToRemove = getBlockNodes ( block . clone ) ;
365
373
$animate . leave ( elementsToRemove ) ;
366
- forEach ( elementsToRemove , function ( element ) { element [ NG_REMOVED ] = true ; } ) ;
374
+ forEach ( elementsToRemove , function ( element ) {
375
+ element [ NG_REMOVED ] = true ;
376
+ } ) ;
367
377
block . scope . $destroy ( ) ;
368
378
}
369
379
}
@@ -381,7 +391,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
381
391
nextNode = previousNode ;
382
392
do {
383
393
nextNode = nextNode . nextSibling ;
384
- } while ( nextNode && nextNode [ NG_REMOVED ] ) ;
394
+ } while ( nextNode && nextNode [ NG_REMOVED ] ) ;
385
395
386
396
if ( getBlockStart ( block ) != nextNode ) {
387
397
// existing item which got moved
@@ -411,13 +421,5 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
411
421
} ;
412
422
}
413
423
} ;
414
-
415
- function getBlockStart ( block ) {
416
- return block . clone [ 0 ] ;
417
- }
418
-
419
- function getBlockEnd ( block ) {
420
- return block . clone [ block . clone . length - 1 ] ;
421
- }
422
424
} ] ;
423
425
0 commit comments