Skip to content

Commit

Permalink
Merge pull request #143 from angular/master
Browse files Browse the repository at this point in the history
Change order of line number geneartion
  • Loading branch information
GulajavaMinistudio committed May 12, 2019
2 parents db80627 + 10d1b19 commit f0bf8f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/ng/directive/ngStyle.js
Expand Up @@ -54,14 +54,7 @@
var ngStyleDirective = ngDirective(function(scope, element, attr) {
scope.$watchCollection(attr.ngStyle, function ngStyleWatchAction(newStyles, oldStyles) {
if (oldStyles && (newStyles !== oldStyles)) {
if (!newStyles) {
newStyles = {};
}
forEach(oldStyles, function(val, style) {
if (newStyles[style] == null) {
newStyles[style] = '';
}
});
forEach(oldStyles, function(val, style) { element.css(style, ''); });
}
if (newStyles) element.css(newStyles);
});
Expand Down
11 changes: 11 additions & 0 deletions test/ng/directive/ngStyleSpec.js
Expand Up @@ -143,6 +143,17 @@ describe('ngStyle', function() {
expect(element.css(postCompStyle)).not.toBe('99px');
});

it('should clear style when the value is false', function() {
scope.styleObj = {'height': '99px', 'width': '88px'};
scope.$apply();
expect(element.css(preCompStyle)).toBe('88px');
expect(element.css(postCompStyle)).toBe('99px');
scope.styleObj = {'height': false, 'width': false};
scope.$apply();
expect(element.css(preCompStyle)).not.toBe('88px');
expect(element.css(postCompStyle)).not.toBe('99px');
});

it('should set style when the value is zero', function() {
scope.styleObj = {'height': '99px', 'width': '88px'};
scope.$apply();
Expand Down

0 comments on commit f0bf8f3

Please sign in to comment.