aboutsummaryrefslogtreecommitdiffstats
path: root/src/directives.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/directives.js')
-rw-r--r--src/directives.js20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/directives.js b/src/directives.js
index f37cdde6..a806e928 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -802,21 +802,11 @@ angularDirective("ng:hide", function(expression, element){
</doc:scenario>
</doc:example>
*/
-angularDirective("ng:style", function(expression, element){
- // TODO(i): this is inefficient (runs on every $digest) and obtrusive (overrides 3rd part css)
- // we should change it in a similar way as I changed ng:class
- return function(element){
- var resetStyle = getStyle(element);
- this.$watch(function(scope){
- var style = scope.$eval(expression) || {}, key, mergedStyle = {};
- for(key in style) {
- if (resetStyle[key] === undefined) resetStyle[key] = '';
- mergedStyle[key] = style[key];
- }
- for(key in resetStyle) {
- mergedStyle[key] = mergedStyle[key] || resetStyle[key];
- }
- element.css(mergedStyle);
+angularDirective("ng:style", function(expression, element) {
+ return function(element) {
+ this.$watch(expression, function(scope, newStyles, oldStyles) {
+ if (oldStyles) forEach(oldStyles, function(val, style) { element.css(style, '');});
+ if (newStyles) element.css(newStyles);
});
};
});