Chromium Code Reviews| 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 /** | 5 /** |
| 6 * A binding delegate used with Polymer elements that | 6 * A binding delegate used with Polymer elements that |
| 7 * allows for complex binding expressions, including | 7 * allows for complex binding expressions, including |
| 8 * property access, function invocation, | 8 * property access, function invocation, |
| 9 * list/map indexing, and two-way filtering. | 9 * list/map indexing, and two-way filtering. |
| 10 * | 10 * |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 : _expr = observe(expr, scope), | 93 : _expr = observe(expr, scope), |
| 94 _scope = scope { | 94 _scope = scope { |
| 95 _expr.onUpdate.listen(_setValue).onError((e) { | 95 _expr.onUpdate.listen(_setValue).onError((e) { |
| 96 _logger.warning("Error evaluating expression '$_expr': ${e.message}"); | 96 _logger.warning("Error evaluating expression '$_expr': ${e.message}"); |
| 97 }); | 97 }); |
| 98 try { | 98 try { |
| 99 update(_expr, _scope); | 99 update(_expr, _scope); |
| 100 _setValue(_expr.currentValue); | 100 _setValue(_expr.currentValue); |
| 101 } on EvalException catch (e) { | 101 } on EvalException catch (e) { |
| 102 _logger.warning("Error evaluating expression '$_expr': ${e.message}"); | 102 _logger.warning("Error evaluating expression '$_expr': ${e.message}"); |
| 103 } catch (e) { | |
|
Siggi Cherem (dart-lang)
2013/10/08 23:41:08
should I merge this and the catch above together?
Jennifer Messerly
2013/10/15 22:47:15
IMO: only EvalException in both places.
justinfagnani
2013/10/16 00:37:08
same, other exceptions are real application except
| |
| 104 _logger.warning("Error evaluating expression '$_expr': ${e}"); | |
| 103 } | 105 } |
| 104 } | 106 } |
| 105 | 107 |
| 106 _setValue(v) { | 108 _setValue(v) { |
| 107 if (v is Comprehension) { | 109 if (v is Comprehension) { |
| 108 // convert the Comprehension into a list of scopes with the loop | 110 // convert the Comprehension into a list of scopes with the loop |
| 109 // variable added to the scope | 111 // variable added to the scope |
| 110 _value = v.iterable.map((i) { | 112 _value = v.iterable.map((i) { |
| 111 var vars = new Map(); | 113 var vars = new Map(); |
| 112 vars[v.identifier] = i; | 114 vars[v.identifier] = i; |
| 113 Scope childScope = new Scope(parent: _scope, variables: vars); | 115 Scope childScope = new Scope(parent: _scope, variables: vars); |
| 114 return childScope; | 116 return childScope; |
| 115 }).toList(growable: false); | 117 }).toList(growable: false); |
| 116 } else { | 118 } else { |
| 117 _value = (_converter == null) ? v : _converter(v); | 119 _value = (_converter == null) ? v : _converter(v); |
| 118 } | 120 } |
| 119 notifyChange(new PropertyChangeRecord(_VALUE)); | 121 notifyChange(new PropertyChangeRecord(_VALUE)); |
| 120 } | 122 } |
| 121 | 123 |
| 122 get value => _value; | 124 get value => _value; |
| 123 | 125 |
| 124 set value(v) { | 126 set value(v) { |
| 125 try { | 127 try { |
| 126 assign(_expr, v, _scope); | 128 assign(_expr, v, _scope); |
| 127 notifyChange(new PropertyChangeRecord(_VALUE)); | 129 notifyChange(new PropertyChangeRecord(_VALUE)); |
| 128 } on EvalException catch (e) { | 130 } catch (e) { |
| 129 // silently swallow binding errors | 131 _logger.warning("Error evaluating expression '$_expr': $e"); |
| 130 } | 132 } |
| 131 } | 133 } |
| 132 | 134 |
| 133 getValueWorkaround(key) { | 135 getValueWorkaround(key) { |
| 134 if (key == _VALUE) return value; | 136 if (key == _VALUE) return value; |
| 135 } | 137 } |
| 136 | 138 |
| 137 setValueWorkaround(key, v) { | 139 setValueWorkaround(key, v) { |
| 138 if (key == _VALUE) value = v; | 140 if (key == _VALUE) value = v; |
| 139 } | 141 } |
| 140 | 142 |
| 141 } | 143 } |
| OLD | NEW |