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

Unified Diff: pkg/mdv/lib/src/input_element.dart

Issue 20149004: [mdv] implement Node.createBinding and Node.createBindings (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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/mdv/lib/src/input_element.dart
diff --git a/pkg/mdv/lib/src/input_element.dart b/pkg/mdv/lib/src/input_element.dart
index 3876ddb437f0624abdaed155761c0bb8f7e3ed98..7e4855eca79fa8b24a2824f5bdcb1a40af459131 100644
--- a/pkg/mdv/lib/src/input_element.dart
+++ b/pkg/mdv/lib/src/input_element.dart
@@ -6,54 +6,20 @@ part of mdv;
/** Extensions to the [InputElement] API. */
class _InputElementExtension extends _ElementExtension {
- _ValueBinding _valueBinding;
- _CheckedBinding _checkedBinding;
-
_InputElementExtension(InputElement node) : super(node);
InputElement get node => super.node;
- void bind(String name, model, String path) {
- switch (name.toLowerCase()) {
- case 'value':
- unbind('value');
- node.attributes.remove('value');
- _valueBinding = new _ValueBinding(node, model, path);
- break;
- case 'checked':
- unbind('checked');
- node.attributes.remove('checked');
- _checkedBinding = new _CheckedBinding(node, model, path);
- break;
- default:
- super.bind(name, model, path);
- break;
+ NodeBinding createBinding(String name, model, String path) {
+ if (name == 'value') {
+ // TODO(rafaelw): Maybe template should remove all binding instructions.
+ node.attributes.remove(name);
+ return new _ValueBinding(node, model, path);
}
- }
-
- void unbind(String name) {
- switch (name.toLowerCase()) {
- case 'value':
- if (_valueBinding != null) {
- _valueBinding.unbind();
- _valueBinding = null;
- }
- break;
- case 'checked':
- if (_checkedBinding != null) {
- _checkedBinding.unbind();
- _checkedBinding = null;
- }
- break;
- default:
- super.unbind(name);
- break;
+ if (name == 'checked') {
+ node.attributes.remove(name);
+ return new _CheckedBinding(node, model, path);
}
- }
-
- void unbindAll() {
- unbind('value');
- unbind('checked');
- super.unbindAll();
+ return super.createBinding(name, model, path);
}
}

Powered by Google App Engine
This is Rietveld 408576698