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

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

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 12 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/core_dom/ng_mustache.dart
diff --git a/third_party/pkg/angular/lib/core_dom/ng_mustache.dart b/third_party/pkg/angular/lib/core_dom/ng_mustache.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ca5ad1e6c52c38c825d61acbcd8d204a3630f687
--- /dev/null
+++ b/third_party/pkg/angular/lib/core_dom/ng_mustache.dart
@@ -0,0 +1,36 @@
+part of angular.core.dom;
+
+@NgDirective(selector: r':contains(/{{.*}}/)')
+class NgTextMustacheDirective {
+ // This Directive is special and does not go through injection.
+ NgTextMustacheDirective(dom.Node element,
+ String markup,
+ Interpolate interpolate,
+ Scope scope,
+ TextChangeListener listener) {
+ Interpolation interpolation = interpolate(markup);
+ interpolation.setter = (text) {
+ element.text = text;
+ if (listener != null) listener.call(text);
+ };
+ interpolation.setter('');
+ scope.$watchSet(interpolation.watchExpressions, interpolation.call, markup.trim());
+ }
+
+}
+
+@NgDirective(selector: r'[*=/{{.*}}/]')
+class NgAttrMustacheDirective {
+ static RegExp ATTR_NAME_VALUE_REGEXP = new RegExp(r'^([^=]+)=(.*)$');
+
+// This Directive is special and does not go through injection.
+ NgAttrMustacheDirective(NodeAttrs attrs, String markup, Interpolate interpolate, Scope scope) {
+ var match = ATTR_NAME_VALUE_REGEXP.firstMatch(markup);
+ var attrName = match[1];
+ Interpolation interpolation = interpolate(match[2]);
+ interpolation.setter = (text) => attrs[attrName] = text;
+ interpolation.setter('');
+ scope.$watchSet(interpolation.watchExpressions, interpolation.call, markup.trim());
+ }
+}
+

Powered by Google App Engine
This is Rietveld 408576698