| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 getInstanceModel(Element template, model) { | 84 getInstanceModel(Element template, model) { |
| 85 if (model is! Scope) { | 85 if (model is! Scope) { |
| 86 var _scope = new Scope(model: model, variables: globals); | 86 var _scope = new Scope(model: model, variables: globals); |
| 87 return _scope; | 87 return _scope; |
| 88 } | 88 } |
| 89 return model; | 89 return model; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 class _Binding extends ChangeNotifierBase { | 93 class _Binding extends ChangeNotifier { |
| 94 final Scope _scope; | 94 final Scope _scope; |
| 95 final ExpressionObserver _expr; | 95 final ExpressionObserver _expr; |
| 96 final _converter; | 96 final _converter; |
| 97 var _value; | 97 var _value; |
| 98 | 98 |
| 99 _Binding(Expression expr, Scope scope, [this._converter]) | 99 _Binding(Expression expr, Scope scope, [this._converter]) |
| 100 : _expr = observe(expr, scope), | 100 : _expr = observe(expr, scope), |
| 101 _scope = scope { | 101 _scope = scope { |
| 102 _expr.onUpdate.listen(_setValue).onError((e) { | 102 _expr.onUpdate.listen(_setValue).onError((e) { |
| 103 _logger.warning("Error evaluating expression '$_expr': ${e.message}"); | 103 _logger.warning("Error evaluating expression '$_expr': ${e.message}"); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 130 @reflectable get value => _value; | 130 @reflectable get value => _value; |
| 131 | 131 |
| 132 @reflectable set value(v) { | 132 @reflectable set value(v) { |
| 133 try { | 133 try { |
| 134 assign(_expr, v, _scope); | 134 assign(_expr, v, _scope); |
| 135 } on EvalException catch (e) { | 135 } on EvalException catch (e) { |
| 136 // silently swallow binding errors | 136 // silently swallow binding errors |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 } | 139 } |
| OLD | NEW |