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

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

Issue 256553002: Revert "Update all Angular libs (run update_all.sh)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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..cf7229b17a902b4a8299ce25198e471a7a464656
--- /dev/null
+++ b/third_party/pkg/angular/lib/core_dom/ng_mustache.dart
@@ -0,0 +1,62 @@
+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,
+ AstParser parser,
+ FilterMap filters) {
+ Interpolation interpolation = interpolate(markup);
+ interpolation.setter = (text) => element.text = text;
+
+ List items = interpolation.expressions.map((exp) {
+ return parser(exp, filters:filters);
+ }).toList();
+ AST ast = new PureFunctionAST('[[$markup]]', new ArrayFn(), items);
+ scope.watch(ast, interpolation.call, readOnly: true);
+ }
+
+}
+
+@NgDirective(selector: r'[*=/{{.*}}/]')
+class NgAttrMustacheDirective {
+ // This Directive is special and does not go through injection.
+ NgAttrMustacheDirective(NodeAttrs attrs,
+ String markup,
+ Interpolate interpolate,
+ Scope scope,
+ AstParser parser,
+ FilterMap filters) {
+ var eqPos = markup.indexOf('=');
+ var attrName = markup.substring(0, eqPos);
+ var attrValue = markup.substring(eqPos + 1);
+ Interpolation interpolation = interpolate(attrValue);
+ var lastValue = markup;
+ interpolation.setter = (text) {
+ if (lastValue != text) {
+ lastValue = attrs[attrName] = text;
+ }
+ };
+ // TODO(misko): figure out how to remove call to setter. It slows down
+ // Block instantiation
+ interpolation.setter('');
+
+ List items = interpolation.expressions.map((exp) {
+ return parser(exp, filters:filters);
+ }).toList();
+ AST ast = new PureFunctionAST('[[$markup]]', new ArrayFn(), items);
+ /*
+ Attribute bindings are tricky. They need to be resolved on digest
+ inline with components so that any bindings to component can
+ be resolved before the component attach method. But once the
+ component is attached we need to run on the flush cycle rather
+ then digest cycle.
+ */
+ // TODO(misko): figure out how to get most of these on observe rather then watch.
+ scope.watch(ast, interpolation.call);
+ }
+}
+
« no previous file with comments | « third_party/pkg/angular/lib/core_dom/ng_element.dart ('k') | third_party/pkg/angular/lib/core_dom/node_cursor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698