OLD | NEW |
1 /// A simple tree API that results from parsing html. Intended to be compatible | 1 /// A simple tree API that results from parsing html. Intended to be compatible |
2 /// with dart:html, but it is missing many types and APIs. | 2 /// with dart:html, but it is missing many types and APIs. |
3 library dom; | 3 library dom; |
4 | 4 |
5 // TODO(jmesserly): lots to do here. Originally I wanted to generate this using | 5 // TODO(jmesserly): lots to do here. Originally I wanted to generate this using |
6 // our Blink IDL generator, but another idea is to directly use the excellent | 6 // our Blink IDL generator, but another idea is to directly use the excellent |
7 // http://dom.spec.whatwg.org/ and http://html.spec.whatwg.org/ and just | 7 // http://dom.spec.whatwg.org/ and http://html.spec.whatwg.org/ and just |
8 // implement that. | 8 // implement that. |
9 | 9 |
10 import 'dart:collection'; | 10 import 'dart:collection'; |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 } | 435 } |
436 | 436 |
437 // TODO(jmesserly): Elements should have a pointer back to their document | 437 // TODO(jmesserly): Elements should have a pointer back to their document |
438 class Element extends Node with _ParentNode, _ElementAndDocument { | 438 class Element extends Node with _ParentNode, _ElementAndDocument { |
439 final String namespaceUri; | 439 final String namespaceUri; |
440 | 440 |
441 /// The [local name](http://dom.spec.whatwg.org/#concept-element-local-name) | 441 /// The [local name](http://dom.spec.whatwg.org/#concept-element-local-name) |
442 /// of this element. | 442 /// of this element. |
443 final String localName; | 443 final String localName; |
444 | 444 |
| 445 // TODO(jmesserly): consider using an Expando for this, and put it in |
| 446 // dom_parsing. Need to check the performance affect. |
| 447 /// The source span of the end tag this element, if it was created by the |
| 448 /// [HtmlParser]. May be `null` if does not have an implicit end tag. |
| 449 FileSpan endSourceSpan; |
| 450 |
445 Element._(this.localName, [this.namespaceUri]) : super._(); | 451 Element._(this.localName, [this.namespaceUri]) : super._(); |
446 | 452 |
447 Element.tag(this.localName) | 453 Element.tag(this.localName) |
448 : namespaceUri = Namespaces.html, | 454 : namespaceUri = Namespaces.html, |
449 super._(); | 455 super._(); |
450 | 456 |
451 static final _START_TAG_REGEXP = new RegExp('<(\\w+)'); | 457 static final _START_TAG_REGEXP = new RegExp('<(\\w+)'); |
452 | 458 |
453 static final _CUSTOM_PARENT_TAG_MAP = const { | 459 static final _CUSTOM_PARENT_TAG_MAP = const { |
454 'body': 'html', | 460 'body': 'html', |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 | 995 |
990 class _ConcatTextVisitor extends TreeVisitor { | 996 class _ConcatTextVisitor extends TreeVisitor { |
991 final _str = new StringBuffer(); | 997 final _str = new StringBuffer(); |
992 | 998 |
993 String toString() => _str.toString(); | 999 String toString() => _str.toString(); |
994 | 1000 |
995 visitText(Text node) { | 1001 visitText(Text node) { |
996 _str.write(node.data); | 1002 _str.write(node.data); |
997 } | 1003 } |
998 } | 1004 } |
OLD | NEW |