OLD | NEW |
1 /** | 1 /** |
2 * A simple tree API that results from parsing html. Intended to be compatible | 2 * A simple tree API that results from parsing html. Intended to be compatible |
3 * with dart:html, but right now it resembles the classic JS DOM. | 3 * with dart:html, but right now it resembles the classic JS DOM. |
4 */ | 4 */ |
5 library dom; | 5 library dom; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'package:source_maps/span.dart' show FileSpan; | 8 import 'package:source_maps/span.dart' show FileSpan; |
9 | 9 |
10 import 'src/constants.dart'; | 10 import 'src/constants.dart'; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 /** | 147 /** |
148 * Return a shallow copy of the current node i.e. a node with the same | 148 * Return a shallow copy of the current node i.e. a node with the same |
149 * name and attributes but with no parent or child nodes. | 149 * name and attributes but with no parent or child nodes. |
150 */ | 150 */ |
151 Node clone(); | 151 Node clone(); |
152 | 152 |
153 String get namespace => null; | 153 String get namespace => null; |
154 | 154 |
155 int get nodeType; | 155 int get nodeType; |
156 | 156 |
| 157 /** *Deprecated* use [text], [Text.data] or [Comment.data]. */ |
| 158 @deprecated String get value => null; |
| 159 |
| 160 /** *Deprecated* use [nodeType]. */ |
| 161 @deprecated int get $dom_nodeType => nodeType; |
| 162 |
157 String get outerHtml { | 163 String get outerHtml { |
158 var str = new StringBuffer(); | 164 var str = new StringBuffer(); |
159 _addOuterHtml(str); | 165 _addOuterHtml(str); |
160 return str.toString(); | 166 return str.toString(); |
161 } | 167 } |
162 | 168 |
163 String get innerHtml { | 169 String get innerHtml { |
164 var str = new StringBuffer(); | 170 var str = new StringBuffer(); |
165 _addInnerHtml(str); | 171 _addInnerHtml(str); |
166 return str.toString(); | 172 return str.toString(); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 } | 432 } |
427 | 433 |
428 DocumentType clone() => new DocumentType(tagName, publicId, systemId); | 434 DocumentType clone() => new DocumentType(tagName, publicId, systemId); |
429 } | 435 } |
430 | 436 |
431 class Text extends Node { | 437 class Text extends Node { |
432 String data; | 438 String data; |
433 | 439 |
434 Text(this.data) : super(null); | 440 Text(this.data) : super(null); |
435 | 441 |
| 442 /** *Deprecated* use [data]. */ |
| 443 @deprecated String get value => data; |
| 444 @deprecated set value(String x) { data = x; } |
| 445 |
436 int get nodeType => Node.TEXT_NODE; | 446 int get nodeType => Node.TEXT_NODE; |
437 | 447 |
438 String toString() => '"$data"'; | 448 String toString() => '"$data"'; |
439 | 449 |
440 void _addOuterHtml(StringBuffer str) { | 450 void _addOuterHtml(StringBuffer str) { |
441 // Don't escape text for certain elements, notably <script>. | 451 // Don't escape text for certain elements, notably <script>. |
442 if (rcdataElements.contains(parent.tagName) || | 452 if (rcdataElements.contains(parent.tagName) || |
443 parent.tagName == 'plaintext') { | 453 parent.tagName == 'plaintext') { |
444 str.write(data); | 454 str.write(data); |
445 } else { | 455 } else { |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 | 917 |
908 class _ConcatTextVisitor extends TreeVisitor { | 918 class _ConcatTextVisitor extends TreeVisitor { |
909 final _str = new StringBuffer(); | 919 final _str = new StringBuffer(); |
910 | 920 |
911 String toString() => _str.toString(); | 921 String toString() => _str.toString(); |
912 | 922 |
913 visitText(Text node) { | 923 visitText(Text node) { |
914 _str.write(node.data); | 924 _str.write(node.data); |
915 } | 925 } |
916 } | 926 } |
OLD | NEW |