Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit e5c0142

Browse files
committed
fix(ngClass): update if value set before first digest
1 parent 3b15fe7 commit e5c0142

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/directives/ng_class.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class NgClassAttrDirective {
1313
currentSet = current.split(' ');
1414
}
1515

16-
if (previous == null) {
16+
if (previous == null || previous == current /* first digest */) {
1717
previousSet = [];
1818
} else {
1919
previousSet = previous.split(' ');

test/directives/ng_class_spec.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ main() {
77
var compile, element, rootScope;
88

99
beforeEach(inject((Scope scope, Compiler compiler, Injector injector) {
10+
rootScope = scope;
11+
1012
compile = (html, [applyFn]) {
1113
element = $(html);
12-
rootScope = scope;
1314
compiler(element)(injector, element);
1415
scope.$apply(applyFn);
1516
};
@@ -75,5 +76,12 @@ main() {
7576
expect(element).toHaveClass('third');
7677
expect(element).toHaveClass('original');
7778
});
79+
80+
81+
it('should update value that was set before compilation', () {
82+
rootScope['active'] = 'something';
83+
compile('<div ng-class="active"></div>');
84+
expect(element).toHaveClass('something');
85+
});
7886
});
7987
}

0 commit comments

Comments
 (0)