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

Side by Side Diff: third_party/pkg/angular/lib/core_dom/directive.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, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 part of angular.core.dom; 1 part of angular.core.dom;
2 2
3 /** 3 /**
4 * Callback function used to notify of attribute changes. 4 * Callback function used to notify of attribute changes.
5 */ 5 */
6 typedef AttributeChanged(String newValue); 6 typedef AttributeChanged(String newValue);
7 7
8 /** 8 /**
9 * Callback function used to notify of text changes.
10 */
11 abstract class TextChangeListener{
12 call(String text);
13 }
14
15 /**
16 * NodeAttrs is a facade for element attributes. The facade is responsible 9 * NodeAttrs is a facade for element attributes. The facade is responsible
17 * for normalizing attribute names as well as allowing access to the 10 * for normalizing attribute names as well as allowing access to the
18 * value of the directive. 11 * value of the directive.
19 */ 12 */
20 class NodeAttrs { 13 class NodeAttrs {
21 final dom.Element element; 14 final dom.Element element;
22 15
23 Map<String, List<AttributeChanged>> _observers; 16 Map<String, List<AttributeChanged>> _observers;
24 17
25 NodeAttrs(this.element); 18 NodeAttrs(this.element);
26 19
27 operator [](String attributeName) => 20 operator [](String attributeName) =>
28 element.attributes[snakecase(attributeName, '-')]; 21 element.attributes[attributeName];
29 22
30 operator []=(String attributeName, String value) { 23 operator []=(String attributeName, String value) {
31 var snakeName = snakecase(attributeName, '-');
32 if (value == null) { 24 if (value == null) {
33 element.attributes.remove(snakeName); 25 element.attributes.remove(attributeName);
34 } else { 26 } else {
35 element.attributes[snakeName] = value; 27 element.attributes[attributeName] = value;
36 } 28 }
37 if (_observers != null && _observers.containsKey(attributeName)) { 29 if (_observers != null && _observers.containsKey(attributeName)) {
38 _observers[attributeName].forEach((fn) => fn(value)); 30 _observers[attributeName].forEach((fn) => fn(value));
39 } 31 }
40 } 32 }
41 33
42 /** 34 /**
43 * Observe changes to the attribute by invoking the [AttributeChanged] 35 * Observe changes to the attribute by invoking the [AttributeChanged]
44 * function. On registration the [AttributeChanged] function gets invoked 36 * function. On registration the [AttributeChanged] function gets invoked
45 * synchronise with the current value. 37 * synchronise with the current value.
46 */ 38 */
47 observe(String attributeName, AttributeChanged notifyFn) { 39 observe(String attributeName, AttributeChanged notifyFn) {
48 if (_observers == null) { 40 if (_observers == null) {
49 _observers = new Map<String, List<AttributeChanged>>(); 41 _observers = new Map<String, List<AttributeChanged>>();
50 } 42 }
51 if (!_observers.containsKey(attributeName)) { 43 if (!_observers.containsKey(attributeName)) {
52 _observers[attributeName] = new List<AttributeChanged>(); 44 _observers[attributeName] = new List<AttributeChanged>();
53 } 45 }
54 _observers[attributeName].add(notifyFn); 46 _observers[attributeName].add(notifyFn);
55 notifyFn(this[attributeName]); 47 notifyFn(this[attributeName]);
56 } 48 }
57 49
58 void forEach(void f(String k, String v)) { 50 void forEach(void f(String k, String v)) {
59 element.attributes.forEach((k, v) => f(camelcase(k), v)); 51 element.attributes.forEach(f);
60 } 52 }
61 53
62 bool containsKey(String attributeName) => 54 bool containsKey(String attributeName) =>
63 element.attributes.containsKey(snakecase(attributeName, '-')); 55 element.attributes.containsKey(attributeName);
64 56
65 Iterable<String> get keys => 57 Iterable<String> get keys =>
66 element.attributes.keys.map((name) => camelcase(name)); 58 element.attributes.keys;
67 } 59 }
68 60
69 /** 61 /**
70 * TemplateLoader is an asynchronous access to ShadowRoot which is 62 * TemplateLoader is an asynchronous access to ShadowRoot which is
71 * loaded asynchronously. It allows a Component to be notified when its 63 * loaded asynchronously. It allows a Component to be notified when its
72 * ShadowRoot is ready. 64 * ShadowRoot is ready.
73 */ 65 */
74 class TemplateLoader { 66 class TemplateLoader {
75 final async.Future<dom.ShadowRoot> _template; 67 final async.Future<dom.ShadowRoot> _template;
76 68
77 async.Future<dom.ShadowRoot> get template => _template; 69 async.Future<dom.ShadowRoot> get template => _template;
78 70
79 TemplateLoader(this._template); 71 TemplateLoader(this._template);
80 } 72 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/core_dom/compiler.dart ('k') | third_party/pkg/angular/lib/core_dom/directive_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698