Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: pkg/third_party/html5lib/lib/dom.dart

Issue 315173005: Add "last" setter to List. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
855 void set length(int newLength) { 859 void set length(int newLength) {
856 final len = this.length; 860 final len = this.length;
857 if (newLength >= len) { 861 if (newLength >= len) {
858 return; 862 return;
859 } else if (newLength < 0) { 863 } else if (newLength < 0) {
860 throw new ArgumentError("Invalid list length"); 864 throw new ArgumentError("Invalid list length");
861 } 865 }
862 866
863 removeRange(newLength, len); 867 removeRange(newLength, len);
864 } 868 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 1015
1012 class _ConcatTextVisitor extends TreeVisitor { 1016 class _ConcatTextVisitor extends TreeVisitor {
1013 final _str = new StringBuffer(); 1017 final _str = new StringBuffer();
1014 1018
1015 String toString() => _str.toString(); 1019 String toString() => _str.toString();
1016 1020
1017 visitText(Text node) { 1021 visitText(Text node) {
1018 _str.write(node.data); 1022 _str.write(node.data);
1019 } 1023 }
1020 } 1024 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698