Skip to content

Commit f0bf8f3

Browse files
Merge pull request #143 from angular/master
Change order of line number geneartion
2 parents db80627 + 10d1b19 commit f0bf8f3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/ng/directive/ngStyle.js

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

test/ng/directive/ngStyleSpec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,17 @@ describe('ngStyle', function() {
143143
expect(element.css(postCompStyle)).not.toBe('99px');
144144
});
145145

146+
it('should clear style when the value is false', 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': false, 'width': false};
152+
scope.$apply();
153+
expect(element.css(preCompStyle)).not.toBe('88px');
154+
expect(element.css(postCompStyle)).not.toBe('99px');
155+
});
156+
146157
it('should set style when the value is zero', function() {
147158
scope.styleObj = {'height': '99px', 'width': '88px'};
148159
scope.$apply();

0 commit comments

Comments
 (0)