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