| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * Part of the template compilation that concerns with extracting information | 6 * Part of the template compilation that concerns with extracting information |
| 7 * from the HTML parse tree. | 7 * from the HTML parse tree. |
| 8 */ | 8 */ |
| 9 library analyzer; | 9 library analyzer; |
| 10 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 visitElementInfo(info); | 81 visitElementInfo(info); |
| 82 | 82 |
| 83 if (_parent == null) { | 83 if (_parent == null) { |
| 84 _fileInfo.bodyInfo = info; | 84 _fileInfo.bodyInfo = info; |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 void visitElementInfo(ElementInfo info) { | 88 void visitElementInfo(ElementInfo info) { |
| 89 var node = info.node; | 89 var node = info.node; |
| 90 | 90 |
| 91 _ensureParentHasQuery(info); | |
| 92 | |
| 93 if (node.id != '') info.identifier = '_${toCamelCase(node.id)}'; | 91 if (node.id != '') info.identifier = '_${toCamelCase(node.id)}'; |
| 94 if (node.tagName == 'body' || (_currentInfo is ComponentInfo | 92 if (node.tagName == 'body' || (_currentInfo is ComponentInfo |
| 95 && (_currentInfo as ComponentInfo).template == node)) { | 93 && (_currentInfo as ComponentInfo).template == node)) { |
| 96 info.isRoot = true; | 94 info.isRoot = true; |
| 97 info.identifier = '_root'; | 95 info.identifier = '_root'; |
| 98 } | 96 } |
| 99 | 97 |
| 100 node.attributes.forEach((name, value) { | 98 node.attributes.forEach((name, value) { |
| 101 visitAttribute(node, info, name, value); | 99 visitAttribute(node, info, name, value); |
| 102 }); | 100 }); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 122 | 120 |
| 123 var savedParent = _parent; | 121 var savedParent = _parent; |
| 124 _parent = info; | 122 _parent = info; |
| 125 | 123 |
| 126 // Invoke super to visit children. | 124 // Invoke super to visit children. |
| 127 super.visitElement(node); | 125 super.visitElement(node); |
| 128 _currentInfo = lastInfo; | 126 _currentInfo = lastInfo; |
| 129 | 127 |
| 130 _parent = savedParent; | 128 _parent = savedParent; |
| 131 | 129 |
| 132 if (info.identifier == null && _needsIdentifier(info)) { | 130 if (_needsIdentifier(info)) { |
| 133 var id = '__e-$_uniqueId'; | 131 _ensureParentHasQuery(info); |
| 134 info.identifier = toCamelCase(id); | 132 if (info.identifier == null) { |
| 135 // If it's not created in code, we'll query the element by it's id. | 133 var id = '__e-$_uniqueId'; |
| 136 if (!info.createdInCode) node.attributes['id'] = id; | 134 info.identifier = toCamelCase(id); |
| 137 _uniqueId++; | 135 // If it's not created in code, we'll query the element by it's id. |
| 136 if (!info.createdInCode) node.attributes['id'] = id; |
| 137 _uniqueId++; |
| 138 } |
| 138 } | 139 } |
| 139 } | 140 } |
| 140 | 141 |
| 141 /** | 142 /** |
| 142 * If this [info] is not created in code, ensure that whichever parent element | 143 * If this [info] is not created in code, ensure that whichever parent element |
| 143 * is created in code has been marked appropriately, so we get an identifier. | 144 * is created in code has been marked appropriately, so we get an identifier. |
| 144 */ | 145 */ |
| 145 static void _ensureParentHasQuery(ElementInfo info) { | 146 static void _ensureParentHasQuery(ElementInfo info) { |
| 146 if (info.isRoot || info.createdInCode) return; | 147 if (info.isRoot || info.createdInCode) return; |
| 147 | 148 |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 end = text.indexOf('}}', start); | 750 end = text.indexOf('}}', start); |
| 750 if (end < 0) { | 751 if (end < 0) { |
| 751 start = length; | 752 start = length; |
| 752 return false; | 753 return false; |
| 753 } | 754 } |
| 754 // For consistency, start and end both include the curly braces. | 755 // For consistency, start and end both include the curly braces. |
| 755 end += 2; | 756 end += 2; |
| 756 return true; | 757 return true; |
| 757 } | 758 } |
| 758 } | 759 } |
| OLD | NEW |