| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of template_binding; | 5 part of template_binding; |
| 6 | 6 |
| 7 /** Extensions to the [Text] API. */ | 7 /** Extensions to the [Text] API. */ |
| 8 class _TextExtension extends NodeBindExtension { | 8 class _TextExtension extends NodeBindExtension { |
| 9 _TextExtension(Text node) : super._(node); | 9 _TextExtension(Text node) : super._(node); |
| 10 | 10 |
| 11 Bindable bind(String name, value, {bool oneTime: false}) { | 11 Bindable bind(String name, value, {bool oneTime: false}) { |
| 12 // Dart note: 'text' instead of 'textContent' to match the DOM property. | 12 // Dart note: 'text' instead of 'textContent' to match the DOM property. |
| 13 if (name != 'text') { | 13 if (name != 'text') { |
| 14 return super.bind(name, value, oneTime: oneTime); | 14 return super.bind(name, value, oneTime: oneTime); |
| 15 } | 15 } |
| 16 if (oneTime) { | 16 if (oneTime) { |
| 17 _updateText(value); | 17 _updateText(value); |
| 18 return null; | 18 return null; |
| 19 } | 19 } |
| 20 | 20 |
| 21 unbind(name); | |
| 22 _open(value, _updateText); | 21 _open(value, _updateText); |
| 23 return bindings[name] = value; | 22 return _maybeUpdateBindings(name, value); |
| 24 } | 23 } |
| 25 | 24 |
| 26 _updateText(value) { | 25 _updateText(value) { |
| 27 _node.text = _sanitizeValue(value); | 26 _node.text = _sanitizeValue(value); |
| 28 } | 27 } |
| 29 } | 28 } |
| 30 | 29 |
| 31 /** Called to sanitize the value before it is assigned into the property. */ | 30 /** Called to sanitize the value before it is assigned into the property. */ |
| 32 _sanitizeValue(value) => value == null ? '' : '$value'; | 31 _sanitizeValue(value) => value == null ? '' : '$value'; |
| OLD | NEW |