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 part of template_binding; | 5 part of template_binding; |
6 | 6 |
7 abstract class _InputBinding extends NodeBinding { | 7 abstract class _InputBinding extends NodeBinding { |
8 StreamSubscription _eventSub; | 8 StreamSubscription _eventSub; |
9 | 9 |
10 _InputBinding(node, name, model, path): super(node, name, model, path) { | 10 _InputBinding(node, name, model, path): super(node, name, model, path) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // <optgroup> iterating and then for <option>. | 141 // <optgroup> iterating and then for <option>. |
142 // | 142 // |
143 // Unlike the JavaScript implemenation, we don't have a special | 143 // Unlike the JavaScript implemenation, we don't have a special |
144 // "Object.observe" event loop to schedule on. | 144 // "Object.observe" event loop to schedule on. |
145 // (See the the "ensureScheduled" function: | 145 // (See the the "ensureScheduled" function: |
146 // https://github.com/Polymer/mdv/commit/9a51ad7ed74a292bf71662cea28acbd151f
f65c8) | 146 // https://github.com/Polymer/mdv/commit/9a51ad7ed74a292bf71662cea28acbd151f
f65c8) |
147 // | 147 // |
148 // Instead we use scheduleMicrotask. Each <template repeat> needs a delay of | 148 // Instead we use scheduleMicrotask. Each <template repeat> needs a delay of |
149 // 2: | 149 // 2: |
150 // * once to happen after the child _TemplateIterator is created | 150 // * once to happen after the child _TemplateIterator is created |
151 // * once to be after _TemplateIterator.inputs CompoundBinding resolve | 151 // * once to be after _TemplateIterator's CompoundPathObserver resolve |
152 // And then we need to do this delay sequence twice: | 152 // And then we need to do this delay sequence twice: |
153 // * once for OPTGROUP | 153 // * once for OPTGROUP |
154 // * once for OPTION. | 154 // * once for OPTION. |
155 // The resulting 2 * 2 is our maxRetries. | 155 // The resulting 2 * 2 is our maxRetries. |
| 156 // |
156 // TODO(jmesserly): a much better approach would be to find the nested | 157 // TODO(jmesserly): a much better approach would be to find the nested |
157 // <template> and wait on some future that completes when it has expanded. | 158 // <template> and wait on some future that completes when it has expanded. |
158 var maxRetries = 4; | 159 var maxRetries = 4; |
159 delaySetSelectedIndex() { | 160 delaySetSelectedIndex() { |
160 if (!_tryUpdateValue(newValue) && maxRetries-- > 0) { | 161 if (!_tryUpdateValue(newValue) && maxRetries-- > 0) { |
161 scheduleMicrotask(delaySetSelectedIndex); | 162 scheduleMicrotask(delaySetSelectedIndex); |
162 } | 163 } |
163 } | 164 } |
164 | 165 |
165 scheduleMicrotask(delaySetSelectedIndex); | 166 scheduleMicrotask(delaySetSelectedIndex); |
(...skipping 20 matching lines...) Expand all Loading... |
186 | 187 |
187 // TODO(jmesserly,sigmund): I wonder how many bindings typically convert from | 188 // TODO(jmesserly,sigmund): I wonder how many bindings typically convert from |
188 // one type to another (e.g. value-as-number) and whether it is useful to | 189 // one type to another (e.g. value-as-number) and whether it is useful to |
189 // have something like a int/num binding converter (either as a base class or | 190 // have something like a int/num binding converter (either as a base class or |
190 // a wrapper). | 191 // a wrapper). |
191 static int _toInt(value) { | 192 static int _toInt(value) { |
192 if (value is String) return int.parse(value, onError: (_) => 0); | 193 if (value is String) return int.parse(value, onError: (_) => 0); |
193 return value is int ? value : 0; | 194 return value is int ? value : 0; |
194 } | 195 } |
195 } | 196 } |
OLD | NEW |