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 from declaration/events.js | 5 /// Code from declaration/events.js |
6 part of polymer; | 6 part of polymer; |
7 | 7 |
8 /// An extension of [polymer_expressions.PolymerExpressions] that adds support | 8 /// An extension of [polymer_expressions.PolymerExpressions] that adds support |
9 /// for binding events using `on-eventName` using [PolymerEventBindings]. | 9 /// for binding events using `on-eventName` using [PolymerEventBindings]. |
10 // TODO(jmesserly): the JS layering is a bit odd, with polymer-dev implementing | 10 // TODO(jmesserly): the JS layering is a bit odd, with polymer-dev implementing |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 var sub = node.on[eventType].listen(handler); | 85 var sub = node.on[eventType].listen(handler); |
86 | 86 |
87 if (oneTime) return null; | 87 if (oneTime) return null; |
88 return new _EventBindable(sub, path); | 88 return new _EventBindable(sub, path); |
89 }; | 89 }; |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 | 93 |
94 class _EventBindable extends Bindable { | 94 class _EventBindable extends Bindable { |
95 final StreamSubscription _sub; | 95 StreamSubscription _sub; |
96 final String _path; | 96 final String _path; |
97 | 97 |
98 _EventBindable(this._sub, this._path); | 98 _EventBindable(this._sub, this._path); |
99 | 99 |
100 // TODO(rafaelw): This is really pointless work. Aside from the cost | 100 // TODO(rafaelw): This is really pointless work. Aside from the cost |
101 // of these allocations, NodeBind is going to setAttribute back to its | 101 // of these allocations, NodeBind is going to setAttribute back to its |
102 // current value. Fixing this would mean changing the TemplateBinding | 102 // current value. Fixing this would mean changing the TemplateBinding |
103 // binding delegate API. | 103 // binding delegate API. |
104 get value => '{{ $_path }}'; | 104 get value => '{{ $_path }}'; |
105 | 105 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return map; | 151 return map; |
152 }(); | 152 }(); |
153 | 153 |
154 // Dart note: we need this function because we have additional renames JS does | 154 // Dart note: we need this function because we have additional renames JS does |
155 // not have. The JS renames are simply case differences, whereas we have ones | 155 // not have. The JS renames are simply case differences, whereas we have ones |
156 // like doubleclick -> dblclick and stripping the webkit prefix. | 156 // like doubleclick -> dblclick and stripping the webkit prefix. |
157 String _eventNameFromType(String eventType) { | 157 String _eventNameFromType(String eventType) { |
158 final result = _reverseEventTranslations[eventType]; | 158 final result = _reverseEventTranslations[eventType]; |
159 return result != null ? result : eventType; | 159 return result != null ? result : eventType; |
160 } | 160 } |
OLD | NEW |