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

Unified Diff: pkg/template_binding/lib/src/text.dart

Issue 132403010: big update to observe, template_binding, polymer (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
Index: pkg/template_binding/lib/src/text.dart
diff --git a/pkg/template_binding/lib/src/text.dart b/pkg/template_binding/lib/src/text.dart
index ecb25814d0cdf5f603b0ebcee3ece0930c88f01c..1f94683d8973ef31e5ddccdc771b55331878adbd 100644
--- a/pkg/template_binding/lib/src/text.dart
+++ b/pkg/template_binding/lib/src/text.dart
@@ -8,20 +8,24 @@ part of template_binding;
class _TextExtension extends NodeBindExtension {
_TextExtension(Text node) : super._(node);
- NodeBinding bind(String name, model, [String path]) {
+ bind(String name, value, {bool oneTime: false}) {
// Dart note: 'text' instead of 'textContent' to match the DOM property.
if (name != 'text') {
- return super.bind(name, model, path);
+ return super.bind(name, value, oneTime: oneTime);
}
+ if (oneTime) {
+ return _updateText(value);
+ }
+
unbind(name);
- return bindings[name] = new _TextBinding(_node, model, path);
+ _open(value, _updateText);
+ return bindings[name] = value;
}
-}
-class _TextBinding extends NodeBinding {
- _TextBinding(node, model, path) : super(node, 'text', model, path);
-
- void valueChanged(newValue) {
- node.text = sanitizeBoundValue(newValue);
+ _updateText(value) {
+ _node.text = _sanitizeValue(value);
}
}
+
+/** Called to sanitize the value before it is assigned into the property. */
+_sanitizeValue(value) => value == null ? '' : '$value';

Powered by Google App Engine
This is Rietveld 408576698