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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 new List<Element>.from(_childNodes.where((n) => n is Element)); | 845 new List<Element>.from(_childNodes.where((n) => n is Element)); |
846 | 846 |
847 void forEach(void f(Element element)) { | 847 void forEach(void f(Element element)) { |
848 _filtered.forEach(f); | 848 _filtered.forEach(f); |
849 } | 849 } |
850 | 850 |
851 void operator []=(int index, Element value) { | 851 void operator []=(int index, Element value) { |
852 this[index].replaceWith(value); | 852 this[index].replaceWith(value); |
853 } | 853 } |
854 | 854 |
855 void set last(Element value) { | |
856 this.last.replaceWith(value); | |
857 } | |
858 | |
859 void set length(int newLength) { | 855 void set length(int newLength) { |
860 final len = this.length; | 856 final len = this.length; |
861 if (newLength >= len) { | 857 if (newLength >= len) { |
862 return; | 858 return; |
863 } else if (newLength < 0) { | 859 } else if (newLength < 0) { |
864 throw new ArgumentError("Invalid list length"); | 860 throw new ArgumentError("Invalid list length"); |
865 } | 861 } |
866 | 862 |
867 removeRange(newLength, len); | 863 removeRange(newLength, len); |
868 } | 864 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 | 1011 |
1016 class _ConcatTextVisitor extends TreeVisitor { | 1012 class _ConcatTextVisitor extends TreeVisitor { |
1017 final _str = new StringBuffer(); | 1013 final _str = new StringBuffer(); |
1018 | 1014 |
1019 String toString() => _str.toString(); | 1015 String toString() => _str.toString(); |
1020 | 1016 |
1021 visitText(Text node) { | 1017 visitText(Text node) { |
1022 _str.write(node.data); | 1018 _str.write(node.data); |
1023 } | 1019 } |
1024 } | 1020 } |
OLD | NEW |