Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: third_party/pkg/angular/lib/directive/ng_style.dart

Issue 180873006: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review feedback Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/lib/directive/ng_style.dart
diff --git a/third_party/pkg/angular/lib/directive/ng_style.dart b/third_party/pkg/angular/lib/directive/ng_style.dart
index 2f0b4ca358585bb3e89bda5735d7c95b21c3c9ee..1bfe9b1eafc8c379f6b918cd4a0d2b298351aa22 100644
--- a/third_party/pkg/angular/lib/directive/ng_style.dart
+++ b/third_party/pkg/angular/lib/directive/ng_style.dart
@@ -1,45 +1,45 @@
part of angular.directive;
/**
- * The `ngStyle` directive allows you to set CSS style on an HTML element conditionally.
+ * The `ngStyle` directive allows you to set CSS style on an HTML element
+ * conditionally.
*
* @example
- <span ng-style="{color:'red'}">Sample Text</span>
+ * <span ng-style="{color:'red'}">Sample Text</span>
*/
@NgDirective(
selector: '[ng-style]',
map: const { 'ng-style': '@styleExpression'})
class NgStyleDirective {
- dom.Element _element;
- Scope _scope;
+ final dom.Element _element;
+ final Scope _scope;
+ final AstParser _parser;
String _styleExpression;
+ Watch _watch;
- NgStyleDirective(this._element, this._scope);
-
- Function _removeWatch = () => null;
- var _lastStyles;
+ NgStyleDirective(this._element, this._scope, this._parser);
/**
* ng-style attribute takes an expression which evaluates to an
- * object whose keys are CSS style names and values are corresponding values for those CSS
- * keys.
+ * object whose keys are CSS style names and values are corresponding values
+ * for those CSS keys.
*/
set styleExpression(String value) {
_styleExpression = value;
- _removeWatch();
- _removeWatch = _scope.$watchCollection(_styleExpression, _onStyleChange);
+ if (_watch != null) _watch.remove();
+ _watch = _scope.watch(_parser(_styleExpression, collection: true), _onStyleChange);
}
- _onStyleChange(Map newStyles) {
- dom.CssStyleDeclaration css = _element.style;
- if (_lastStyles != null) {
- _lastStyles.forEach((val, style) { css.setProperty(val, ''); });
- }
- _lastStyles = newStyles;
+ _onStyleChange(MapChangeRecord mapChangeRecord, _) {
+ if (mapChangeRecord != null) {
+ dom.CssStyleDeclaration css = _element.style;
+ fn(MapKeyValue kv) => css.setProperty(kv.key, kv.currentValue == null ? '' : kv.currentValue);
- if (newStyles != null) {
- newStyles.forEach((val, style) { css.setProperty(val, style); });
+ mapChangeRecord
+ ..forEachRemoval(fn)
+ ..forEachChange(fn)
+ ..forEachAddition(fn);
}
}
}
« no previous file with comments | « third_party/pkg/angular/lib/directive/ng_src_boolean.dart ('k') | third_party/pkg/angular/lib/directive/ng_switch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698