Skip to content
Permalink
Browse files

perf(ngStyleDirective): use $watchCollection

Since we are simply watching a flat object collection it is more performant
to use $watchCollection than a deepWatch...

Closes #10535
  • Loading branch information
PatrickJS authored and petebacondarwin committed Dec 20, 2014
1 parent 3a8f3dc commit 4c8d8ad5083d9dd17c0b8480339d5f95943f1b71
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/ng/directive/ngStyle.js
@@ -47,10 +47,10 @@
</example>
*/
var ngStyleDirective = ngDirective(function(scope, element, attr) {
scope.$watch(attr.ngStyle, function ngStyleWatchAction(newStyles, oldStyles) {
scope.$watchCollection(attr.ngStyle, function ngStyleWatchAction(newStyles, oldStyles) {
if (oldStyles && (newStyles !== oldStyles)) {
forEach(oldStyles, function(val, style) { element.css(style, '');});
}
if (newStyles) element.css(newStyles);
}, true);
});
});

0 comments on commit 4c8d8ad

Please sign in to comment.
You can’t perform that action at this time.