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

Side by Side Diff: pkg/template_binding/lib/src/input_bindings.dart

Issue 50203004: port TemplateBinding to ed3266266e751b5ab1f75f8e0509d0d5f0ef35d8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 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
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
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 }
OLDNEW
« no previous file with comments | « pkg/template_binding/lib/src/element.dart ('k') | pkg/template_binding/lib/src/instance_binding_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698