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

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

Issue 257423008: 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/mustache.dart
diff --git a/third_party/pkg/angular/lib/core_dom/mustache.dart b/third_party/pkg/angular/lib/core_dom/mustache.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1cc242c15fd3d26dd6480ce5d67a6a47cd4558fe
--- /dev/null
+++ b/third_party/pkg/angular/lib/core_dom/mustache.dart
@@ -0,0 +1,62 @@
+part of angular.core.dom_internal;
+
+// This Directive is special and does not go through injection.
+@Decorator(selector: r':contains(/{{.*}}/)')
+class TextMustache {
+ final dom.Node _element;
+
+ TextMustache(this._element,
+ String template,
+ Interpolate interpolate,
+ Scope scope,
+ FormatterMap formatters) {
+ String expression = interpolate(template);
+
+ scope.watch(expression,
+ _updateMarkup,
+ canChangeModel: false,
+ formatters: formatters);
+ }
+
+ void _updateMarkup(text, previousText) {
+ _element.text = text;
+ }
+}
+
+// This Directive is special and does not go through injection.
+@Decorator(selector: r'[*=/{{.*}}/]')
+class AttrMustache {
+ bool _hasObservers;
+ Watch _watch;
+ NodeAttrs _attrs;
+ String _attrName;
+
+ // This Directive is special and does not go through injection.
+ AttrMustache(this._attrs,
+ String template,
+ Interpolate interpolate,
+ Scope scope,
+ FormatterMap formatters) {
+ var eqPos = template.indexOf('=');
+ _attrName = template.substring(0, eqPos);
+ String expression = interpolate(template.substring(eqPos + 1));
+
+ _updateMarkup('', template);
+
+ _attrs.listenObserverChanges(_attrName, (hasObservers) {
+ if (_hasObservers != hasObservers) {
+ _hasObservers = hasObservers;
+ if (_watch != null) _watch.remove();
+ _watch = scope.watch(expression, _updateMarkup, formatters: formatters,
+ canChangeModel: _hasObservers);
+ }
+ });
+ }
+
+ void _updateMarkup(text, previousText) {
+ if (text != previousText && !(previousText == null && text == '')) {
+ _attrs[_attrName] = text;
+ }
+ }
+}
+
« no previous file with comments | « third_party/pkg/angular/lib/core_dom/module_internal.dart ('k') | third_party/pkg/angular/lib/core_dom/ng_element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698