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

Side by Side Diff: pkg/mdv/lib/src/select_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, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 mdv; 5 part of mdv;
6 6
7 /** Extensions to the [SelectElement] API. */ 7 /** Extensions to the [SelectElement] API. */
8 class _SelectElementExtension extends _ElementExtension { 8 class _SelectElementExtension extends _ElementExtension {
9 _SelectedIndexBinding _valueBinding;
10
11 _SelectElementExtension(SelectElement node) : super(node); 9 _SelectElementExtension(SelectElement node) : super(node);
12 10
13 SelectElement get node => super.node; 11 SelectElement get node => super.node;
14 12
15 void bind(String name, model, String path) { 13 NodeBinding createBinding(String name, model, String path) {
16 if (name.toLowerCase() == 'selectedindex') { 14 if (name.toLowerCase() === 'selectedindex') {
17 unbind('selectedindex'); 15 // TODO(rafaelw): Maybe template should remove all binding instructions.
18 node.attributes.remove('selectedindex'); 16 node.attributes.remove(name);
19 _valueBinding = new _SelectedIndexBinding(node, model, path); 17 return new _SelectedIndexBinding(node, model, path);
20 return;
21 } 18 }
22 super.bind(name, model, path); 19 return super.createBinding(name, model, path);
23 }
24
25 void unbind(String name) {
26 if (name.toLowerCase() == 'selectedindex' && _valueBinding != null) {
27 _valueBinding.unbind();
28 _valueBinding = null;
29 return;
30 }
31 super.unbind(name);
32 }
33
34 void unbindAll() {
35 unbind('selectedindex');
36 super.unbindAll();
37 } 20 }
38 } 21 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698