Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 6c67719

Browse files
petrovalexmhevery
authored andcommitted
fix(ngClassEven/Odd): filtering/ordering and repeater
Closes #1076
1 parent cebd015 commit 6c67719

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/ng/directive/ngClassSpec.js

+44
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,48 @@ describe('ngClass', function() {
234234
expect(element.hasClass('two')).toBeFalsy();
235235
expect(element.hasClass('too')).toBeFalsy();
236236
}));
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+
}));
237281
});

0 commit comments

Comments
 (0)