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]) { |