This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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 @@ -274,6 +274,28 @@ describe('ngClass', function() {
274
274
} ) ) ;
275
275
276
276
277
+ it ( 'should update ngClassOdd/Even when an item is added to the model' , inject ( function ( $rootScope , $compile ) {
278
+ element = $compile ( '<ul>' +
279
+ '<li ng-repeat="i in items" ' +
280
+ 'ng-class-odd="\'odd\'" ng-class-even="\'even\'">i</li>' +
281
+ '<ul>' ) ( $rootScope ) ;
282
+ $rootScope . items = [ 'b' , 'c' , 'd' ] ;
283
+ $rootScope . $digest ( ) ;
284
+
285
+ $rootScope . items . unshift ( 'a' ) ;
286
+ $rootScope . $digest ( ) ;
287
+
288
+ var e1 = jqLite ( element [ 0 ] . childNodes [ 1 ] ) ;
289
+ var e4 = jqLite ( element [ 0 ] . childNodes [ 7 ] ) ;
290
+
291
+ expect ( e1 . hasClass ( 'odd' ) ) . toBeTruthy ( ) ;
292
+ expect ( e1 . hasClass ( 'even' ) ) . toBeFalsy ( ) ;
293
+
294
+ expect ( e4 . hasClass ( 'even' ) ) . toBeTruthy ( ) ;
295
+ expect ( e4 . hasClass ( 'odd' ) ) . toBeFalsy ( ) ;
296
+ } ) ) ;
297
+
298
+
277
299
it ( 'should update ngClassOdd/Even when model is changed by filtering' , inject ( function ( $rootScope , $compile ) {
278
300
element = $compile ( '<ul>' +
279
301
'<li ng-repeat="i in items track by $index" ' +
You can’t perform that action at this time.
0 commit comments