| Index: pkg/mdv/lib/src/select_element.dart
|
| diff --git a/pkg/mdv/lib/src/select_element.dart b/pkg/mdv/lib/src/select_element.dart
|
| index 34ab99ce11385d64c725956cacea22901e54ca53..4e564c35b59f9ac3ce708fadeecc640a8e5ccb6d 100644
|
| --- a/pkg/mdv/lib/src/select_element.dart
|
| +++ b/pkg/mdv/lib/src/select_element.dart
|
| @@ -51,9 +51,22 @@ class _SelectedIndexBinding extends _InputBinding {
|
| }
|
|
|
| // The binding may wish to bind to an <option> which has not yet been
|
| - // produced by a child <template>. Delay a maximum of twice -- once for
|
| - // iterating <optgroup> and once for <option>.
|
| - var maxRetries = 2;
|
| + // produced by a child <template>. Furthermore, we may need to wait for
|
| + // <optgroup> iterating and then for <option>.
|
| + //
|
| + // Unlike the JavaScript MDV, we don't have a special "Object.observe" event
|
| + // loop to schedule on. (See the the "ensureScheduled" function:
|
| + // https://github.com/Polymer/mdv/commit/9a51ad7ed74a292bf71662cea28acbd151ff65c8)
|
| + //
|
| + // Instead we use runAsync. Each <template repeat> needs a delay of 3:
|
| + // * once to happen after the child _TemplateIterator is created
|
| + // * once to be after _TemplateIterator.inputs CompoundBinding resolve
|
| + // * once to be after _TemplateIterator._valueBinding PathObserver fires
|
| + // And then we need to do this delay sequence twice:
|
| + // * once for OPTGROUP
|
| + // * once for OPTION.
|
| + // The resulting 2 * 3 is our maxRetries.
|
| + var maxRetries = 6;
|
| delaySetSelectedIndex() {
|
| if (newValue > element.length && --maxRetries >= 0) {
|
| runAsync(delaySetSelectedIndex);
|
| @@ -62,11 +75,6 @@ class _SelectedIndexBinding extends _InputBinding {
|
| }
|
| }
|
|
|
| - // TODO(jmesserly): we aren't matching MDV here. They schedule "model=" to
|
| - // happen async and then delay using the same scheduler. By using "runAsync"
|
| - // we're going to happen quite a bit later.
|
| - // We need to port the "ensureScheduled" function:
|
| - // https://github.com/Polymer/mdv/commit/9a51ad7ed74a292bf71662cea28acbd151ff65c8
|
| runAsync(delaySetSelectedIndex);
|
| }
|
|
|
|
|