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

Unified Diff: client/html/src/NodeWrappingImplementation.dart

Issue 9199002: Support various range methods on NodeList. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge with HEAD Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/html/release/htmlimpl.dart ('k') | client/tests/client/html/NodeTests.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/html/src/NodeWrappingImplementation.dart
diff --git a/client/html/src/NodeWrappingImplementation.dart b/client/html/src/NodeWrappingImplementation.dart
index 77d13d22867893a597e59401aabc5acdc02b255d..5a89e5e8c4e28ae87415e4d7d679b510a5ae198c 100644
--- a/client/html/src/NodeWrappingImplementation.dart
+++ b/client/html/src/NodeWrappingImplementation.dart
@@ -75,7 +75,7 @@ class _ChildrenNodeList implements NodeList {
}
void operator []=(int index, Node value) {
- _childNodes[index] = LevelDom.unwrap(value);
+ _node.replaceChild(LevelDom.unwrap(value), _childNodes[index]);
}
void set length(int newLength) {
@@ -112,11 +112,39 @@ class _ChildrenNodeList implements NodeList {
}
void setRange(int start, int length, List from, [int startFrom = 0]) {
- throw const NotImplementedException();
+ // TODO(nweiz): remove these IndexOutOfRange checks once Frog has bounds
+ // checking for List indexing
+ if (start < 0) {
+ throw new IndexOutOfRangeException(start);
+ } else if (startFrom < 0) {
+ throw new IndexOutOfRangeException(startFrom);
+ } else if (length < 0) {
+ throw new IllegalArgumentException("negative length $length");
+ } else if (start + length > this.length) {
+ throw new IndexOutOfRangeException(Math.min(this.length, start));
+ } else if (startFrom + length > from.length) {
+ throw new IndexOutOfRangeException(Math.min(from.length, startFrom));
+ }
+
+ for (var i = 0; i < length; i++) {
+ this[start + i] = from[startFrom + i];
+ }
}
void removeRange(int start, int length) {
- throw const NotImplementedException();
+ // TODO(nweiz): remove these IndexOutOfRange checks once Frog has bounds
+ // checking for List indexing
+ if (start < 0) {
+ throw new IndexOutOfRangeException(start);
+ } else if (length < 0) {
+ throw new IllegalArgumentException("negative length $length");
+ } else if (start + length > this.length) {
+ throw new IndexOutOfRangeException(Math.min(this.length, start));
+ }
+
+ for (var i = 0; i < length; i++) {
+ this[start].remove();
+ }
}
void insertRange(int start, int length, [initialValue = null]) {
@@ -124,7 +152,21 @@ class _ChildrenNodeList implements NodeList {
}
List getRange(int start, int length) {
- throw const NotImplementedException();
+ // TODO(nweiz): remove these IndexOutOfRange checks once Frog has bounds
+ // checking for List indexing
+ if (start < 0) {
+ throw new IndexOutOfRangeException(start);
+ } else if (length < 0) {
+ throw new IllegalArgumentException("negative length $length");
+ } else if (start + length > this.length) {
+ throw new IndexOutOfRangeException(Math.min(this.length, start));
+ }
+
+ var nodes = <Node>[];
Jacob 2012/01/17 18:14:53 make this return a Nodelist rather than a List so
nweiz 2012/01/17 23:23:22 How will this work type-wise? The user only access
+ for (var i = 0; i < length; i++) {
+ nodes.add(this[start + i]);
+ }
+ return nodes;
}
int indexOf(Node element, [int start = 0]) {
« no previous file with comments | « client/html/release/htmlimpl.dart ('k') | client/tests/client/html/NodeTests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698