@@ -234,4 +234,48 @@ describe('ngClass', function() {
234
234
expect ( element . hasClass ( 'two' ) ) . toBeFalsy ( ) ;
235
235
expect ( element . hasClass ( 'too' ) ) . toBeFalsy ( ) ;
236
236
} ) ) ;
237
+
238
+
239
+ it ( 'should update ngClassOdd/Even when model is changed by filtering' , inject ( function ( $rootScope , $compile ) {
240
+ element = $compile ( '<ul>' +
241
+ '<li ng-repeat="i in items" ' +
242
+ 'ng-class-odd="\'odd\'" ng-class-even="\'even\'"></li>' +
243
+ '<ul>' ) ( $rootScope ) ;
244
+ $rootScope . items = [ 'a' , 'b' , 'a' ] ;
245
+ $rootScope . $digest ( ) ;
246
+
247
+ $rootScope . items = [ 'a' , 'a' ] ;
248
+ $rootScope . $digest ( ) ;
249
+
250
+ var e1 = jqLite ( element [ 0 ] . childNodes [ 1 ] ) ;
251
+ var e2 = jqLite ( element [ 0 ] . childNodes [ 2 ] ) ;
252
+
253
+ expect ( e1 . hasClass ( 'odd' ) ) . toBeTruthy ( ) ;
254
+ expect ( e1 . hasClass ( 'even' ) ) . toBeFalsy ( ) ;
255
+
256
+ expect ( e2 . hasClass ( 'even' ) ) . toBeTruthy ( ) ;
257
+ expect ( e2 . hasClass ( 'odd' ) ) . toBeFalsy ( ) ;
258
+ } ) ) ;
259
+
260
+
261
+ it ( 'should update ngClassOdd/Even when model is changed by sorting' , inject ( function ( $rootScope , $compile ) {
262
+ element = $compile ( '<ul>' +
263
+ '<li ng-repeat="i in items" ' +
264
+ 'ng-class-odd="\'odd\'" ng-class-even="\'even\'">i</li>' +
265
+ '<ul>' ) ( $rootScope ) ;
266
+ $rootScope . items = [ 'a' , 'b' ] ;
267
+ $rootScope . $digest ( ) ;
268
+
269
+ $rootScope . items = [ 'b' , 'a' ] ;
270
+ $rootScope . $digest ( ) ;
271
+
272
+ var e1 = jqLite ( element [ 0 ] . childNodes [ 1 ] ) ;
273
+ var e2 = jqLite ( element [ 0 ] . childNodes [ 2 ] ) ;
274
+
275
+ expect ( e1 . hasClass ( 'odd' ) ) . toBeTruthy ( ) ;
276
+ expect ( e1 . hasClass ( 'even' ) ) . toBeFalsy ( ) ;
277
+
278
+ expect ( e2 . hasClass ( 'even' ) ) . toBeTruthy ( ) ;
279
+ expect ( e2 . hasClass ( 'odd' ) ) . toBeFalsy ( ) ;
280
+ } ) ) ;
237
281
} ) ;
0 commit comments