aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Compagner2010-07-15 03:08:55 +0800
committerMisko Hevery2010-07-15 07:40:27 +0800
commit0a57273f0000421639c926d4d180680e3a64c0f7 (patch)
tree069df1c8fc9ce1ae39af468ada45e6597d085eb0
parent32361d03a147213747762e17d279639666ed85fb (diff)
downloadangular.js-0a57273f0000421639c926d4d180680e3a64c0f7.tar.bz2
fix undefine style
-rw-r--r--src/directives.js2
-rw-r--r--test/directivesSpec.js7
2 files changed, 8 insertions, 1 deletions
diff --git a/src/directives.js b/src/directives.js
index a333c4c4..6b81d864 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -255,7 +255,7 @@ angularDirective("ng:hide", function(expression, element){
angularDirective("ng:style", function(expression, element){
return function(element){
this.$onEval(function(){
- element.css(this.$eval(expression));
+ element.css(this.$eval(expression) || {});
}, element);
};
});
diff --git a/test/directivesSpec.js b/test/directivesSpec.js
index df0b5b94..ef4814bf 100644
--- a/test/directivesSpec.js
+++ b/test/directivesSpec.js
@@ -174,6 +174,13 @@ describe("directives", function(){
expect(element.css('color')).toEqual('red');
});
+ it('should silently ignore undefined ng:style', function() {
+ var scope = compile('<div ng:style="myStyle"></div>');
+ scope.$eval();
+ dump(sortedHtml(element));
+ expect(element.hasClass('ng-exception')).toBeFalsy();
+ });
+
it('should ng:show', function(){
var scope = compile('<div ng:hide="hide"></div>');
scope.$eval();