@@ -181,8 +181,8 @@ describe('uiSortable', function() {
181
181
it ( 'should work when "helper: clone" option is used' , function ( ) {
182
182
inject ( function ( $compile , $rootScope ) {
183
183
var elementTop , elementBottom ;
184
- elementTop = $compile ( '<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsTop"><li ng-repeat="item in itemsTop" id="s-top-{{$index}}" class="sortable-item">{{ item }}</li></ul>' ) ( $rootScope ) ;
185
- elementBottom = $compile ( '<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsBottom"><li ng-repeat="item in itemsBottom" id="s-bottom-{{$index}}" class="sortable-item">{{ item }}</li></ul>' ) ( $rootScope ) ;
184
+ elementTop = $compile ( '<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsTop"><li ng-repeat="item in itemsTop track by $index " id="s-top-{{$index}}" class="sortable-item">{{ item }}</li></ul>' ) ( $rootScope ) ;
185
+ elementBottom = $compile ( '<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsBottom"><li ng-repeat="item in itemsBottom track by $index " id="s-bottom-{{$index}}" class="sortable-item">{{ item }}</li></ul>' ) ( $rootScope ) ;
186
186
$rootScope . $apply ( function ( ) {
187
187
$rootScope . itemsTop = [ 'Top One' , 'Top Two' , 'Top Three' ] ;
188
188
$rootScope . itemsBottom = [ 'Bottom One' , 'Bottom Two' , 'Bottom Three' ] ;
@@ -197,16 +197,16 @@ describe('uiSortable', function() {
197
197
var li1 = elementTop . find ( ':eq(0)' ) ;
198
198
var li2 = elementBottom . find ( ':eq(0)' ) ;
199
199
simulateElementDrag ( li1 , li2 , 'below' ) ;
200
- expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top Two' , 'Top Three' ] ) ;
200
+ expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top One' , 'Top Two', 'Top Three' ] ) ;
201
201
expect ( $rootScope . itemsBottom ) . toEqual ( [ 'Bottom One' , 'Top One' , 'Bottom Two' , 'Bottom Three' ] ) ;
202
202
expect ( $rootScope . itemsTop ) . toEqual ( listContent ( elementTop ) ) ;
203
203
expect ( $rootScope . itemsBottom ) . toEqual ( listContent ( elementBottom ) ) ;
204
204
205
205
li1 = elementBottom . find ( ':eq(1)' ) ;
206
206
li2 = elementTop . find ( ':eq(1)' ) ;
207
207
simulateElementDrag ( li1 , li2 , { place : 'above' , extradx : - 20 , extrady : - 10 } ) ;
208
- expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top Two ' , 'Top One' , 'Top Three' ] ) ;
209
- expect ( $rootScope . itemsBottom ) . toEqual ( [ 'Bottom One' , 'Bottom Two' , 'Bottom Three' ] ) ;
208
+ expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top One ' , 'Top One' , 'Top Two ', 'Top Three' ] ) ;
209
+ expect ( $rootScope . itemsBottom ) . toEqual ( [ 'Bottom One' , 'Top One' , ' Bottom Two', 'Bottom Three' ] ) ;
210
210
expect ( $rootScope . itemsTop ) . toEqual ( listContent ( elementTop ) ) ;
211
211
expect ( $rootScope . itemsBottom ) . toEqual ( listContent ( elementBottom ) ) ;
212
212
@@ -218,8 +218,8 @@ describe('uiSortable', function() {
218
218
it ( 'should work when "placeholder" and "helper: clone" options are used' , function ( ) {
219
219
inject ( function ( $compile , $rootScope ) {
220
220
var elementTop , elementBottom ;
221
- elementTop = $compile ( '<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsTop"><li ng-repeat="item in itemsTop" id="s-top-{{$index}}" class="sortable-item">{{ item }}</li></ul>' ) ( $rootScope ) ;
222
- elementBottom = $compile ( '<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsBottom"><li ng-repeat="item in itemsBottom" id="s-bottom-{{$index}}" class="sortable-item">{{ item }}</li></ul>' ) ( $rootScope ) ;
221
+ elementTop = $compile ( '<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsTop"><li ng-repeat="item in itemsTop track by $index " id="s-top-{{$index}}" class="sortable-item">{{ item }}</li></ul>' ) ( $rootScope ) ;
222
+ elementBottom = $compile ( '<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsBottom"><li ng-repeat="item in itemsBottom track by $index " id="s-bottom-{{$index}}" class="sortable-item">{{ item }}</li></ul>' ) ( $rootScope ) ;
223
223
$rootScope . $apply ( function ( ) {
224
224
$rootScope . itemsTop = [ 'Top One' , 'Top Two' , 'Top Three' ] ;
225
225
$rootScope . itemsBottom = [ 'Bottom One' , 'Bottom Two' , 'Bottom Three' ] ;
@@ -235,16 +235,16 @@ describe('uiSortable', function() {
235
235
var li1 = elementTop . find ( ':eq(0)' ) ;
236
236
var li2 = elementBottom . find ( ':eq(0)' ) ;
237
237
simulateElementDrag ( li1 , li2 , 'below' ) ;
238
- expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top Two' , 'Top Three' ] ) ;
238
+ expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top One' , 'Top Two', 'Top Three' ] ) ;
239
239
expect ( $rootScope . itemsBottom ) . toEqual ( [ 'Bottom One' , 'Top One' , 'Bottom Two' , 'Bottom Three' ] ) ;
240
240
expect ( $rootScope . itemsTop ) . toEqual ( listContent ( elementTop ) ) ;
241
241
expect ( $rootScope . itemsBottom ) . toEqual ( listContent ( elementBottom ) ) ;
242
242
243
243
li1 = elementBottom . find ( ':eq(1)' ) ;
244
244
li2 = elementTop . find ( ':eq(1)' ) ;
245
245
simulateElementDrag ( li1 , li2 , { place : 'above' , extradx : - 20 , extrady : - 10 } ) ;
246
- expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top Two ' , 'Top One' , 'Top Three' ] ) ;
247
- expect ( $rootScope . itemsBottom ) . toEqual ( [ 'Bottom One' , 'Bottom Two' , 'Bottom Three' ] ) ;
246
+ expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top One ' , 'Top One' , 'Top Two ', 'Top Three' ] ) ;
247
+ expect ( $rootScope . itemsBottom ) . toEqual ( [ 'Bottom One' , 'Top One' , ' Bottom Two', 'Bottom Three' ] ) ;
248
248
expect ( $rootScope . itemsTop ) . toEqual ( listContent ( elementTop ) ) ;
249
249
expect ( $rootScope . itemsBottom ) . toEqual ( listContent ( elementBottom ) ) ;
250
250
0 commit comments