OLD | NEW |
1 /// Support code for the tests in this directory. | 1 /// Support code for the tests in this directory. |
2 library support; | 2 library support; |
3 | 3 |
4 import 'dart:io'; | 4 import 'dart:io'; |
5 import 'dart:collection'; | 5 import 'dart:collection'; |
6 import 'package:path/path.dart' as path; | 6 import 'package:path/path.dart' as path; |
7 import 'package:html5lib/src/treebuilder.dart'; | 7 import 'package:html5lib/src/treebuilder.dart'; |
8 import 'package:html5lib/dom.dart'; | 8 import 'package:html5lib/dom.dart'; |
9 import 'package:html5lib/dom_parsing.dart'; | 9 import 'package:html5lib/dom_parsing.dart'; |
10 | 10 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 _str.write(node); | 127 _str.write(node); |
128 visitChildren(node); | 128 visitChildren(node); |
129 } | 129 } |
130 | 130 |
131 visitChildren(Node node) { | 131 visitChildren(Node node) { |
132 indent += 2; | 132 indent += 2; |
133 for (var child in node.nodes) visit(child); | 133 for (var child in node.nodes) visit(child); |
134 indent -= 2; | 134 indent -= 2; |
135 } | 135 } |
136 | 136 |
137 visitDocument(Document node) { | 137 visitDocument(node) { |
138 indent += 1; | 138 indent += 1; |
139 for (var child in node.nodes) visit(child); | 139 for (var child in node.nodes) visit(child); |
140 indent -= 1; | 140 indent -= 1; |
141 } | 141 } |
142 | 142 |
143 visitDocumentFragment(DocumentFragment node) => visitDocument(node); | 143 visitDocumentFragment(DocumentFragment node) => visitDocument(node); |
144 | 144 |
145 visitElement(Element node) { | 145 visitElement(Element node) { |
146 _newline(); | 146 _newline(); |
147 _str.write(node); | 147 _str.write(node); |
148 if (node.attributes.length > 0) { | 148 if (node.attributes.length > 0) { |
149 indent += 2; | 149 indent += 2; |
150 var keys = new List.from(node.attributes.keys); | 150 var keys = new List.from(node.attributes.keys); |
151 keys.sort((x, y) => x.compareTo(y)); | 151 keys.sort((x, y) => x.compareTo(y)); |
152 for (var key in keys) { | 152 for (var key in keys) { |
153 var v = node.attributes[key]; | 153 var v = node.attributes[key]; |
154 if (key is AttributeName) { | 154 if (key is AttributeName) { |
155 AttributeName attr = key; | 155 AttributeName attr = key; |
156 key = "${attr.prefix} ${attr.name}"; | 156 key = "${attr.prefix} ${attr.name}"; |
157 } | 157 } |
158 _newline(); | 158 _newline(); |
159 _str.write('$key="$v"'); | 159 _str.write('$key="$v"'); |
160 } | 160 } |
161 indent -= 2; | 161 indent -= 2; |
162 } | 162 } |
163 visitChildren(node); | 163 visitChildren(node); |
164 } | 164 } |
165 } | 165 } |
OLD | NEW |