| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS implements | 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS implements |
| 8 HiddenInputElement, | 8 HiddenInputElement, |
| 9 SearchInputElement, | 9 SearchInputElement, |
| 10 TextInputElement, | 10 TextInputElement, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 factory InputElement({String type}) { | 31 factory InputElement({String type}) { |
| 32 var e = document.$dom_createElement("input"); | 32 var e = document.$dom_createElement("input"); |
| 33 if (type != null) { | 33 if (type != null) { |
| 34 try { | 34 try { |
| 35 // IE throws an exception for unknown types. | 35 // IE throws an exception for unknown types. |
| 36 e.type = type; | 36 e.type = type; |
| 37 } catch(_) {} | 37 } catch(_) {} |
| 38 } | 38 } |
| 39 return e; | 39 return e; |
| 40 } | 40 } |
| 41 |
| 42 $if DART2JS |
| 43 @Creates('Null') // Set from Dart code; does not instantiate a native type. |
| 44 $endif |
| 45 _ValueBinding _valueBinding; |
| 46 |
| 47 $if DART2JS |
| 48 @Creates('Null') // Set from Dart code; does not instantiate a native type. |
| 49 $endif |
| 50 _CheckedBinding _checkedBinding; |
| 51 |
| 52 @Experimental |
| 53 void bind(String name, model, String path) { |
| 54 switch (name) { |
| 55 case 'value': |
| 56 unbind('value'); |
| 57 attributes.remove('value'); |
| 58 _valueBinding = new _ValueBinding(this, model, path); |
| 59 break; |
| 60 case 'checked': |
| 61 unbind('checked'); |
| 62 attributes.remove('checked'); |
| 63 _checkedBinding = new _CheckedBinding(this, model, path); |
| 64 break; |
| 65 default: |
| 66 // TODO(jmesserly): this should be "super" (http://dartbug.com/10166). |
| 67 // Similar issue for unbind/unbindAll below. |
| 68 Element._bindElement(this, name, model, path); |
| 69 break; |
| 70 } |
| 71 } |
| 72 |
| 73 @Experimental |
| 74 void unbind(String name) { |
| 75 switch (name) { |
| 76 case 'value': |
| 77 if (_valueBinding != null) { |
| 78 _valueBinding.unbind(); |
| 79 _valueBinding = null; |
| 80 } |
| 81 break; |
| 82 case 'checked': |
| 83 if (_checkedBinding != null) { |
| 84 _checkedBinding.unbind(); |
| 85 _checkedBinding = null; |
| 86 } |
| 87 break; |
| 88 default: |
| 89 Element._unbindElement(this, name); |
| 90 break; |
| 91 } |
| 92 } |
| 93 |
| 94 @Experimental |
| 95 void unbindAll() { |
| 96 unbind('value'); |
| 97 unbind('checked'); |
| 98 Element._unbindAllElement(this); |
| 99 } |
| 100 |
| 41 $!MEMBERS | 101 $!MEMBERS |
| 42 } | 102 } |
| 43 | 103 |
| 44 | 104 |
| 45 // Interfaces representing the InputElement APIs which are supported | 105 // Interfaces representing the InputElement APIs which are supported |
| 46 // for the various types of InputElement. From: | 106 // for the various types of InputElement. From: |
| 47 // http://www.w3.org/html/wg/drafts/html/master/forms.html#the-input-element. | 107 // http://www.w3.org/html/wg/drafts/html/master/forms.html#the-input-element. |
| 48 | 108 |
| 49 /** | 109 /** |
| 50 * Exposes the functionality common between all InputElement types. | 110 * Exposes the functionality common between all InputElement types. |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 factory ResetButtonInputElement() => new InputElement(type: 'reset'); | 649 factory ResetButtonInputElement() => new InputElement(type: 'reset'); |
| 590 } | 650 } |
| 591 | 651 |
| 592 /** | 652 /** |
| 593 * A button, with no default behavior. | 653 * A button, with no default behavior. |
| 594 */ | 654 */ |
| 595 abstract class ButtonInputElement implements InputElementBase { | 655 abstract class ButtonInputElement implements InputElementBase { |
| 596 factory ButtonInputElement() => new InputElement(type: 'button'); | 656 factory ButtonInputElement() => new InputElement(type: 'button'); |
| 597 } | 657 } |
| 598 | 658 |
| OLD | NEW |