| 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 template_binding; | 5 part of template_binding; |
| 6 | 6 |
| 7 class _InstanceBindingMap { | 7 class _InstanceBindingMap { |
| 8 final List bindings; | 8 final List bindings; |
| 9 final List<_InstanceBindingMap> children; | 9 final List<_InstanceBindingMap> children; |
| 10 final Node templateRef; | 10 final Node templateRef; |
| 11 final bool hasSubTemplate; | |
| 12 | 11 |
| 13 _InstanceBindingMap._(this.bindings, this.children, this.templateRef, | 12 _InstanceBindingMap._(this.bindings, this.children, this.templateRef); |
| 14 this.hasSubTemplate); | |
| 15 | 13 |
| 16 factory _InstanceBindingMap(Node node, BindingDelegate delegate) { | 14 factory _InstanceBindingMap(Node node, BindingDelegate delegate) { |
| 17 var bindings = _getBindings(node, delegate); | 15 var bindings = _getBindings(node, delegate); |
| 18 | |
| 19 bool hasSubTemplate = false; | |
| 20 Node templateRef = null; | 16 Node templateRef = null; |
| 21 | 17 |
| 22 if (isSemanticTemplate(node)) { | 18 if (isSemanticTemplate(node)) templateRef = node; |
| 23 templateRef = node; | |
| 24 hasSubTemplate = true; | |
| 25 } | |
| 26 | 19 |
| 27 List children = null; | 20 List children = null; |
| 28 for (var c = node.firstChild, i = 0; c != null; c = c.nextNode, i++) { | 21 for (var c = node.firstChild, i = 0; c != null; c = c.nextNode, i++) { |
| 29 var childMap = new _InstanceBindingMap(c, delegate); | 22 var childMap = new _InstanceBindingMap(c, delegate); |
| 30 if (childMap == null) continue; | 23 if (childMap == null) continue; |
| 31 | 24 |
| 32 if (children == null) children = new List(node.nodes.length); | 25 if (children == null) children = new List(node.nodes.length); |
| 33 children[i] = childMap; | 26 children[i] = childMap; |
| 34 if (childMap.hasSubTemplate) { | |
| 35 hasSubTemplate = true; | |
| 36 } | |
| 37 } | 27 } |
| 38 | 28 |
| 39 return new _InstanceBindingMap._(bindings, children, templateRef, | 29 return new _InstanceBindingMap._(bindings, children, templateRef); |
| 40 hasSubTemplate); | |
| 41 } | 30 } |
| 42 } | 31 } |
| 43 | 32 |
| 44 | 33 |
| 45 void _addMapBindings(Node node, _InstanceBindingMap map, model, | 34 void _addMapBindings(Node node, _InstanceBindingMap map, model, |
| 46 BindingDelegate delegate, List bound) { | 35 BindingDelegate delegate, List bound) { |
| 47 if (map == null) return; | 36 if (map == null) return; |
| 48 | 37 |
| 49 if (map.templateRef != null) { | 38 if (map.templateRef != null) { |
| 50 TemplateBindExtension.decorate(node, map.templateRef); | 39 TemplateBindExtension.decorate(node, map.templateRef); |
| 51 if (delegate != null) { | 40 if (delegate != null) { |
| 52 templateBindFallback(node)._bindingDelegate = delegate; | 41 templateBindFallback(node)._bindingDelegate = delegate; |
| 53 } | 42 } |
| 54 } | 43 } |
| 55 | 44 |
| 56 if (map.bindings != null) { | 45 if (map.bindings != null) { |
| 57 _processBindings(map.bindings, node, model, bound); | 46 _processBindings(map.bindings, node, model, bound); |
| 58 } | 47 } |
| 59 | 48 |
| 60 if (map.children == null) return; | 49 if (map.children == null) return; |
| 61 | 50 |
| 62 int i = 0; | 51 int i = 0; |
| 63 for (var c = node.firstChild; c != null; c = c.nextNode) { | 52 for (var c = node.firstChild; c != null; c = c.nextNode) { |
| 64 _addMapBindings(c, map.children[i++], model, delegate, bound); | 53 _addMapBindings(c, map.children[i++], model, delegate, bound); |
| 65 } | 54 } |
| 66 } | 55 } |
| OLD | NEW |