Index: pkg/template_binding/lib/src/template_iterator.dart |
diff --git a/pkg/template_binding/lib/src/template_iterator.dart b/pkg/template_binding/lib/src/template_iterator.dart |
index a2839eaaa0b10bf097e5b3e786634c268ba85e53..fa8adc88afe3aeb234499d87eaff7f0ca57ed72a 100644 |
--- a/pkg/template_binding/lib/src/template_iterator.dart |
+++ b/pkg/template_binding/lib/src/template_iterator.dart |
@@ -257,18 +257,20 @@ class _TemplateIterator extends Bindable { |
_hasIf = directives._if != null; |
_hasRepeat = directives._repeat != null; |
+ var ifValue = true; |
if (_hasIf) { |
_ifOneTime = directives._if.onlyOneTime; |
_ifValue = _processBinding('if', directives._if, template, model); |
+ ifValue = _ifValue; |
// oneTime if & predicate is false. nothing else to do. |
- if (_ifOneTime) { |
- if (!_toBoolean(_ifValue)) { |
- _updateIteratedValue(null); |
- return; |
- } |
- } else { |
- (_ifValue as Bindable).open(_updateIteratedValue); |
+ if (_ifOneTime && !_toBoolean(ifValue)) { |
+ _valueChanged(null); |
+ return; |
+ } |
+ |
+ if (!_ifOneTime) { |
+ ifValue = (ifValue as Bindable).open(_updateIfValue); |
} |
} |
@@ -280,12 +282,42 @@ class _TemplateIterator extends Bindable { |
_value = _processBinding('bind', directives._bind, template, model); |
} |
- if (!_oneTime) _value.open(_updateIteratedValue); |
+ var value = _value; |
+ if (!_oneTime) { |
+ value = _value.open(_updateIteratedValue); |
+ } |
+ |
+ if (!_toBoolean(ifValue)) { |
+ _valueChanged(null); |
+ return; |
+ } |
+ |
+ _updateValue(value); |
+ } |
+ |
+ /** |
Siggi Cherem (dart-lang)
2014/08/13 23:00:26
nit: use /// instead of /** */
jakemac
2014/08/14 18:00:49
Done.
|
+ * Gets the updated value of the bind/repeat. This can potentially call |
+ * user code (if a bindingDelegate is set up) so we try to avoid it if we |
+ * already have the value in hand (from Observer.open). |
+ */ |
+ Object getUpdatedValue() { |
Siggi Cherem (dart-lang)
2014/08/13 23:00:26
I wonder if this could be private too, since it's
jakemac
2014/08/14 18:00:49
Done.
|
+ var value = _value; |
+ // Dart Note: Changed value.discardChanges() to value.value since |
+ // discardChanges is a private function in the dart version. The value |
+ // getter just calls this private function so it has the same effect. |
Siggi Cherem (dart-lang)
2014/08/13 23:00:26
yes - note that this is a Dart note in observe (we
jakemac
2014/08/14 18:00:49
Done.
|
+ if (!_toBoolean(_oneTime)) value = value.value; |
+ return value; |
+ } |
- _updateIteratedValue(null); |
+ void _updateIfValue(ifValue) { |
+ if (!_toBoolean(ifValue)) { |
+ _valueChanged(null); |
+ return; |
+ } |
+ _updateValue(getUpdatedValue()); |
} |
- void _updateIteratedValue(_) { |
+ void _updateIteratedValue(value) { |
if (_hasIf) { |
var ifValue = _ifValue; |
if (!_ifOneTime) ifValue = (ifValue as Bindable).value; |
@@ -295,8 +327,10 @@ class _TemplateIterator extends Bindable { |
} |
} |
- var value = _value; |
- if (!_oneTime) value = (value as Bindable).value; |
+ _updateValue(value); |
+ } |
+ |
+ void _updateValue(Object value) { |
if (!_hasRepeat) value = [value]; |
_valueChanged(value); |
} |