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

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

Issue 148453003: Updating Angular version (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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
« no previous file with comments | « third_party/pkg/angular/lib/core_dom/cookies.dart ('k') | third_party/pkg/angular/lib/core_dom/http.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pkg/angular/lib/core_dom/directive.dart
diff --git a/third_party/pkg/angular/lib/core_dom/directive.dart b/third_party/pkg/angular/lib/core_dom/directive.dart
index 6cf5ce829af15351a21d81f8c0ee80dc17178044..647f954eaf496907abb219bf997a8bcbf8d284d1 100644
--- a/third_party/pkg/angular/lib/core_dom/directive.dart
+++ b/third_party/pkg/angular/lib/core_dom/directive.dart
@@ -12,7 +12,6 @@ abstract class TextChangeListener{
call(String text);
}
-
/**
* NodeAttrs is a facade for element attributes. The facade is responsible
* for normalizing attribute names as well as allowing access to the
@@ -25,17 +24,18 @@ class NodeAttrs {
NodeAttrs(this.element);
- operator [](String name) => element.attributes[_snakeCase(name, '-')];
+ operator [](String attributeName) =>
+ element.attributes[snakecase(attributeName, '-')];
- operator []=(String name, String value) {
- name = _snakeCase(name, '-');
+ operator []=(String attributeName, String value) {
+ var snakeName = snakecase(attributeName, '-');
if (value == null) {
- element.attributes.remove(name);
+ element.attributes.remove(snakeName);
} else {
- element.attributes[name] = value;
+ element.attributes[snakeName] = value;
}
- if (_observers != null && _observers.containsKey(name)) {
- _observers[name].forEach((fn) => fn(value));
+ if (_observers != null && _observers.containsKey(attributeName)) {
+ _observers[attributeName].forEach((fn) => fn(value));
}
}
@@ -45,7 +45,6 @@ class NodeAttrs {
* synchronise with the current value.
*/
observe(String attributeName, AttributeChanged notifyFn) {
- attributeName = _snakeCase(attributeName, '-');
if (_observers == null) {
_observers = new Map<String, List<AttributeChanged>>();
}
@@ -55,6 +54,16 @@ class NodeAttrs {
_observers[attributeName].add(notifyFn);
notifyFn(this[attributeName]);
}
+
+ void forEach(void f(String k, String v)) {
+ element.attributes.forEach((k, v) => f(camelcase(k), v));
+ }
+
+ bool containsKey(String attributeName) =>
+ element.attributes.containsKey(snakecase(attributeName, '-'));
+
+ Iterable<String> get keys =>
+ element.attributes.keys.map((name) => camelcase(name));
}
/**
@@ -69,11 +78,3 @@ class TemplateLoader {
TemplateLoader(this._template);
}
-
-var _SNAKE_CASE_REGEXP = new RegExp("[A-Z]");
-String _snakeCase(String name, [separator = '_']) {
- _snakeReplace(Match match) =>
- (match.start != 0 ? separator : '') + match.group(0).toLowerCase();
-
- return name.replaceAllMapped(_SNAKE_CASE_REGEXP, _snakeReplace);
-}
« no previous file with comments | « third_party/pkg/angular/lib/core_dom/cookies.dart ('k') | third_party/pkg/angular/lib/core_dom/http.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698