| 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 part of mdv; | 5 part of mdv; |
| 6 | 6 |
| 7 /** Extensions to [Element]s that behave as templates. */ | 7 /** Extensions to [Element]s that behave as templates. */ |
| 8 class _TemplateExtension extends _ElementExtension { | 8 class _TemplateExtension extends _ElementExtension { |
| 9 var _model; | 9 var _model; |
| 10 BindingDelegate _bindingDelegate; | 10 BindingDelegate _bindingDelegate; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 BindingDelegate get bindingDelegate => _bindingDelegate; | 67 BindingDelegate get bindingDelegate => _bindingDelegate; |
| 68 | 68 |
| 69 void set bindingDelegate(BindingDelegate value) { | 69 void set bindingDelegate(BindingDelegate value) { |
| 70 _bindingDelegate = value; | 70 _bindingDelegate = value; |
| 71 _ensureSetModelScheduled(); | 71 _ensureSetModelScheduled(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 _ensureSetModelScheduled() { | 74 _ensureSetModelScheduled() { |
| 75 if (_scheduled) return; | 75 if (_scheduled) return; |
| 76 _scheduled = true; | 76 _scheduled = true; |
| 77 runAsync(_setModel); | 77 scheduleMicrotask(_setModel); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void _setModel() { | 80 void _setModel() { |
| 81 _scheduled = false; | 81 _scheduled = false; |
| 82 _addBindings(node, _model, _bindingDelegate); | 82 _addBindings(node, _model, _bindingDelegate); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 class _TemplateBinding extends NodeBinding { | 86 class _TemplateBinding extends NodeBinding { |
| 87 // TODO(jmesserly): MDV uses TemplateIterator as the node, see: | 87 // TODO(jmesserly): MDV uses TemplateIterator as the node, see: |
| 88 // https://github.com/Polymer/mdv/issues/127 | 88 // https://github.com/Polymer/mdv/issues/127 |
| 89 _TemplateBinding(node, name, model, path) | 89 _TemplateBinding(node, name, model, path) |
| 90 : super(node, name, model, path) { | 90 : super(node, name, model, path) { |
| 91 _mdv(node)._templateIterator.inputs.bind(property, model, path); | 91 _mdv(node)._templateIterator.inputs.bind(property, model, path); |
| 92 } | 92 } |
| 93 | 93 |
| 94 // These are no-ops because we don't use the underlying PathObserver. | 94 // These are no-ops because we don't use the underlying PathObserver. |
| 95 void _observePath() {} | 95 void _observePath() {} |
| 96 void boundValueChanged(newValue) {} | 96 void boundValueChanged(newValue) {} |
| 97 | 97 |
| 98 void close() { | 98 void close() { |
| 99 if (closed) return; | 99 if (closed) return; |
| 100 var templateIterator = _mdv(node)._templateIterator; | 100 var templateIterator = _mdv(node)._templateIterator; |
| 101 if (templateIterator != null) templateIterator.inputs.unbind(property); | 101 if (templateIterator != null) templateIterator.inputs.unbind(property); |
| 102 super.close(); | 102 super.close(); |
| 103 } | 103 } |
| 104 } | 104 } |
| OLD | NEW |