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

Commit 08898f6

Browse files
PatrickJSjbedard
authored andcommitted
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
1 parent b4651e5 commit 08898f6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ng/directive/ngStyle.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
</example>
5353
*/
5454
var ngStyleDirective = ngDirective(function(scope, element, attr) {
55-
scope.$watch(attr.ngStyle, function ngStyleWatchAction(newStyles, oldStyles) {
55+
scope.$watchCollection(attr.ngStyle, function ngStyleWatchAction(newStyles, oldStyles) {
5656
if (oldStyles && (newStyles !== oldStyles)) {
5757
forEach(oldStyles, function(val, style) { element.css(style, '');});
5858
}
5959
if (newStyles) element.css(newStyles);
60-
}, true);
60+
});
6161
});

0 commit comments

Comments
 (0)