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

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

Issue 9207020: Add tests for Element#elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/src/Lists.dart ('k') | client/html/src/_Lists.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 5a89e5e8c4e28ae87415e4d7d679b510a5ae198c..82a568c3d597bc38a7caf612d662bf6e0edf7981 100644
--- a/client/html/src/NodeWrappingImplementation.dart
+++ b/client/html/src/NodeWrappingImplementation.dart
@@ -25,23 +25,9 @@ class _ChildrenNodeList implements NodeList {
void forEach(void f(Node element)) => _toList().forEach(f);
- Collection map(f(Node element)) {
- List output = new List();
- forEach((Node element) {
- output.add(f(element));
- });
- return output;
- }
+ Collection map(f(Node element)) => _toList().map(f);
- Collection<Node> filter(bool f(Node element)) {
- List<Node> output = new List<Node>();
- forEach((Node element) {
- if (f(element)) {
- output.add(element);
- }
- });
- return output;
- }
+ Collection<Node> filter(bool f(Node element)) => _toList().filter(f);
bool every(bool f(Node element)) {
for(Node element in this) {
@@ -111,71 +97,25 @@ class _ChildrenNodeList implements NodeList {
throw 'Not impl yet. todo(jacobr)';
}
- void setRange(int start, int length, List from, [int startFrom = 0]) {
- // 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) {
- // 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));
- }
+ void setRange(int start, int length, List from, [int startFrom = 0]) =>
+ Lists.setRange(this, start, length, from, startFrom);
- for (var i = 0; i < length; i++) {
- this[start].remove();
- }
- }
+ void removeRange(int start, int length) =>
+ Lists.removeRange(this, start, length, (i) => this[i].remove());
void insertRange(int start, int length, [initialValue = null]) {
throw const NotImplementedException();
}
- List getRange(int start, int length) {
- // 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>[];
- for (var i = 0; i < length; i++) {
- nodes.add(this[start + i]);
- }
- return nodes;
- }
+ List getRange(int start, int length) => Lists.getRange(this, start, length);
int indexOf(Node element, [int start = 0]) {
- return _Lists.indexOf(this, element, start, this.length);
+ return Lists.indexOf(this, element, start, this.length);
}
int lastIndexOf(Node element, [int start = null]) {
if (start === null) start = length - 1;
- return _Lists.lastIndexOf(this, element, start);
+ return Lists.lastIndexOf(this, element, start);
}
void clear() {
« no previous file with comments | « client/html/src/Lists.dart ('k') | client/html/src/_Lists.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698