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