fix(ngClass): fix watching of an array expression containing an object

Closes #14405
This commit is contained in:
David Rodenas Pico
2016-04-10 00:22:50 +02:00
committed by Georgios Kalpakas
parent 8b9ce885d3
commit b50867001b
2 changed files with 21 additions and 1 deletions
+5 -1
View File
@@ -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);
}
}
}
};
+16
View File
@@ -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() {