Skip to content

Commit f8795a0

Browse files
Merge pull request #114 from angular/master
Enable insertId generation, and update Stackdriver Logging A
2 parents c09dc8b + bb5a7e3 commit f8795a0

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<a name="1.7.5"></a>
2+
# 1.7.5 anti-prettification (2018-10-04)
3+
4+
## Bug Fixes
5+
- **ngClass:** do not break on invalid values
6+
([f3a565](https://github.com/angular/angular.js/commit/f3a565872d802c94bb213944791b11b483d52f73),
7+
[#16697](https://github.com/angular/angular.js/issues/16697),
8+
[#16699](https://github.com/angular/angular.js/issues/16699))
9+
10+
111
<a name="1.7.4"></a>
212
# 1.7.4 interstellar-exploration (2018-09-07)
313

src/ng/directive/ngStyle.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@
5454
var ngStyleDirective = ngDirective(function(scope, element, attr) {
5555
scope.$watchCollection(attr.ngStyle, function ngStyleWatchAction(newStyles, oldStyles) {
5656
if (oldStyles && (newStyles !== oldStyles)) {
57-
forEach(oldStyles, function(val, style) { element.css(style, '');});
57+
if (!newStyles) {
58+
newStyles = {};
59+
}
60+
forEach(oldStyles, function(val, style) {
61+
if (newStyles[style] == null) {
62+
newStyles[style] = '';
63+
}
64+
});
5865
}
5966
if (newStyles) element.css(newStyles);
6067
});

test/ng/directive/ngStyleSpec.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,38 @@ describe('ngStyle', function() {
120120
expect(element.css(preCompStyle)).not.toBe('88px');
121121
expect(element.css(postCompStyle)).not.toBe('99px');
122122
});
123+
124+
it('should clear style when the new model is null', function() {
125+
scope.styleObj = {'height': '99px', 'width': '88px'};
126+
scope.$apply();
127+
expect(element.css(preCompStyle)).toBe('88px');
128+
expect(element.css(postCompStyle)).toBe('99px');
129+
scope.styleObj = null;
130+
scope.$apply();
131+
expect(element.css(preCompStyle)).not.toBe('88px');
132+
expect(element.css(postCompStyle)).not.toBe('99px');
133+
});
134+
135+
it('should clear style when the value is undefined or null', function() {
136+
scope.styleObj = {'height': '99px', 'width': '88px'};
137+
scope.$apply();
138+
expect(element.css(preCompStyle)).toBe('88px');
139+
expect(element.css(postCompStyle)).toBe('99px');
140+
scope.styleObj = {'height': undefined, 'width': null};
141+
scope.$apply();
142+
expect(element.css(preCompStyle)).not.toBe('88px');
143+
expect(element.css(postCompStyle)).not.toBe('99px');
144+
});
145+
146+
it('should set style when the value is zero', function() {
147+
scope.styleObj = {'height': '99px', 'width': '88px'};
148+
scope.$apply();
149+
expect(element.css(preCompStyle)).toBe('88px');
150+
expect(element.css(postCompStyle)).toBe('99px');
151+
scope.styleObj = {'height': 0, 'width': 0};
152+
scope.$apply();
153+
expect(element.css(preCompStyle)).toBe('0px');
154+
expect(element.css(postCompStyle)).toBe('0px');
155+
});
123156
});
124157
});

0 commit comments

Comments
 (0)