| 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 23 matching lines...) Expand all Loading... |
| 34 /** | 34 /** |
| 35 * Creates an instance of the template. | 35 * Creates an instance of the template. |
| 36 */ | 36 */ |
| 37 DocumentFragment createInstance(model, BindingDelegate delegate) { | 37 DocumentFragment createInstance(model, BindingDelegate delegate) { |
| 38 var template = node.ref; | 38 var template = node.ref; |
| 39 if (template == null) template = node; | 39 if (template == null) template = node; |
| 40 | 40 |
| 41 var instance = _createDeepCloneAndDecorateTemplates( | 41 var instance = _createDeepCloneAndDecorateTemplates( |
| 42 template.ref.content, delegate); | 42 template.ref.content, delegate); |
| 43 | 43 |
| 44 if (_instanceCreated != null) _instanceCreated.add(instance); | 44 if (_instanceCreated != null) { |
| 45 for (var callback in _instanceCreated) callback(instance); |
| 46 } |
| 45 | 47 |
| 46 _addBindings(instance, model, delegate); | 48 _addBindings(instance, model, delegate); |
| 47 _addTemplateInstanceRecord(instance, model); | 49 _addTemplateInstanceRecord(instance, model); |
| 48 return instance; | 50 return instance; |
| 49 } | 51 } |
| 50 | 52 |
| 51 /** | 53 /** |
| 52 * The data model which is inherited through the tree. | 54 * The data model which is inherited through the tree. |
| 53 */ | 55 */ |
| 54 get model => _model; | 56 get model => _model; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 void _observePath() {} | 95 void _observePath() {} |
| 94 void boundValueChanged(newValue) {} | 96 void boundValueChanged(newValue) {} |
| 95 | 97 |
| 96 void close() { | 98 void close() { |
| 97 if (closed) return; | 99 if (closed) return; |
| 98 var templateIterator = _mdv(node)._templateIterator; | 100 var templateIterator = _mdv(node)._templateIterator; |
| 99 if (templateIterator != null) templateIterator.inputs.unbind(property); | 101 if (templateIterator != null) templateIterator.inputs.unbind(property); |
| 100 super.close(); | 102 super.close(); |
| 101 } | 103 } |
| 102 } | 104 } |
| OLD | NEW |