fix(ngClass): fix watching of an array expression containing an object
Closes #14405
This commit is contained in:
committed by
Georgios Kalpakas
parent
8b9ce885d3
commit
b50867001b
@@ -78,7 +78,11 @@ function classDirective(name, selector) {
|
||||
updateClasses(oldClasses, newClasses);
|
||||
}
|
||||
}
|
||||
oldVal = shallowCopy(newVal);
|
||||
if (isArray(newVal)) {
|
||||
oldVal = newVal.map(function(v) { return shallowCopy(v); });
|
||||
} else {
|
||||
oldVal = shallowCopy(newVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -409,6 +409,22 @@ describe('ngClass', function() {
|
||||
expect(e2.hasClass('even')).toBeTruthy();
|
||||
expect(e2.hasClass('odd')).toBeFalsy();
|
||||
}));
|
||||
|
||||
it('should support mixed array/object variable with a mutating object',
|
||||
inject(function($rootScope, $compile) {
|
||||
element = $compile('<div ng-class="classVar"></div>')($rootScope);
|
||||
|
||||
$rootScope.classVar = [{orange: true}];
|
||||
$rootScope.$digest();
|
||||
expect(element).toHaveClass('orange');
|
||||
|
||||
$rootScope.classVar[0].orange = false;
|
||||
$rootScope.$digest();
|
||||
|
||||
expect(element).not.toHaveClass('orange');
|
||||
})
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
describe('ngClass animations', function() {
|
||||
|
||||
Reference in New Issue
Block a user