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