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 /// Code for property accessors from declaration/properties.js | 5 /// Code for property accessors from declaration/properties.js |
6 part of polymer; | 6 part of polymer; |
7 | 7 |
8 // Dart note: this matches the property defined by createPropertyAccessor in | 8 // Dart note: this matches the property defined by createPropertyAccessor in |
9 // polymer-dev/src/declarations/properties.js. Unlike Javascript, we can't | 9 // polymer-dev/src/declarations/properties.js. Unlike Javascript, we can't |
10 // override the original property, so we instead ask users to write properties | 10 // override the original property, so we instead ask users to write properties |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 /// The current value of the property. If the property is bound, reading this | 44 /// The current value of the property. If the property is bound, reading this |
45 /// property ensures that the changes are first propagated in order to return | 45 /// property ensures that the changes are first propagated in order to return |
46 /// the latest value. Similarly, when setting this property the binding (if | 46 /// the latest value. Similarly, when setting this property the binding (if |
47 /// any) will be updated too. | 47 /// any) will be updated too. |
48 T get value { | 48 T get value { |
49 if (bindable != null) bindable.deliver(); | 49 if (bindable != null) bindable.deliver(); |
50 return _value; | 50 return _value; |
51 } | 51 } |
52 | 52 |
53 set value(T newValue) { | 53 set value(T newValue) { |
| 54 // Dart Note: The js side makes computed properties read only, and bails |
| 55 // out right here for them (ignoreWrites). For us they are automatically |
| 56 // read only unless you define a setter for them, so we left that out. |
54 if (bindable != null) { | 57 if (bindable != null) { |
55 bindable.value = newValue; | 58 bindable.value = newValue; |
56 } else { | 59 } else { |
57 updateValue(newValue); | 60 updateValue(newValue); |
58 } | 61 } |
59 } | 62 } |
60 | 63 |
61 toString() { | 64 toString() { |
62 var name = smoke.symbolToName(_name); | 65 var name = smoke.symbolToName(_name); |
63 var hasBinding = bindable == null ? '(no-binding)' : '(with-binding)'; | 66 var hasBinding = bindable == null ? '(no-binding)' : '(with-binding)'; |
64 return "[$runtimeType: $_target.$name: $_value $hasBinding]"; | 67 return "[$runtimeType: $_target.$name: $_value $hasBinding]"; |
65 } | 68 } |
66 } | 69 } |
OLD | NEW |