File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ function classDirective(name, selector) {
19
19
scope . $watch ( '$index' , function ( $index , old$index ) {
20
20
// jshint bitwise: false
21
21
var mod = $index & 1 ;
22
- if ( mod !== old$index & 1 ) {
22
+ if ( mod !== ( old$index & 1 ) ) {
23
23
var classes = arrayClasses ( scope . $eval ( attr [ name ] ) ) ;
24
24
mod === selector ?
25
25
addClasses ( classes ) :
Original file line number Diff line number Diff line change @@ -278,6 +278,28 @@ describe('ngClass', function() {
278
278
} ) ) ;
279
279
280
280
281
+ it ( 'should update ngClassOdd/Even when an item is added to the model' , inject ( function ( $rootScope , $compile ) {
282
+ element = $compile ( '<ul>' +
283
+ '<li ng-repeat="i in items" ' +
284
+ 'ng-class-odd="\'odd\'" ng-class-even="\'even\'">i</li>' +
285
+ '<ul>' ) ( $rootScope ) ;
286
+ $rootScope . items = [ 'b' , 'c' , 'd' ] ;
287
+ $rootScope . $digest ( ) ;
288
+
289
+ $rootScope . items . unshift ( 'a' ) ;
290
+ $rootScope . $digest ( ) ;
291
+
292
+ var e1 = jqLite ( element [ 0 ] . childNodes [ 1 ] ) ;
293
+ var e4 = jqLite ( element [ 0 ] . childNodes [ 7 ] ) ;
294
+
295
+ expect ( e1 . hasClass ( 'odd' ) ) . toBeTruthy ( ) ;
296
+ expect ( e1 . hasClass ( 'even' ) ) . toBeFalsy ( ) ;
297
+
298
+ expect ( e4 . hasClass ( 'even' ) ) . toBeTruthy ( ) ;
299
+ expect ( e4 . hasClass ( 'odd' ) ) . toBeFalsy ( ) ;
300
+ } ) ) ;
301
+
302
+
281
303
it ( 'should update ngClassOdd/Even when model is changed by filtering' , inject ( function ( $rootScope , $compile ) {
282
304
element = $compile ( '<ul>' +
283
305
'<li ng-repeat="i in items track by $index" ' +
You can’t perform that action at this time.
0 commit comments