Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 9998b8d

Browse files
author
Kai Compagner
committed
fix undefine style
1 parent 32361d0 commit 9998b8d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/directives.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ angularDirective("ng:hide", function(expression, element){
255255
angularDirective("ng:style", function(expression, element){
256256
return function(element){
257257
this.$onEval(function(){
258-
element.css(this.$eval(expression));
258+
element.css(this.$eval(expression) || {});
259259
}, element);
260260
};
261261
});

test/directivesSpec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ describe("directives", function(){
174174
expect(element.css('color')).toEqual('red');
175175
});
176176

177+
it('should silently ignore undefined ng:style', function() {
178+
var scope = compile('<div ng:style="myStyle"></div>');
179+
scope.$eval();
180+
dump(sortedHtml(element));
181+
expect(element.hasClass('ng-exception')).toBeFalsy();
182+
});
183+
177184
it('should ng:show', function(){
178185
var scope = compile('<div ng:hide="hide"></div>');
179186
scope.$eval();

0 commit comments

Comments
 (0)