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

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

Issue 9178030: 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/release/htmlimpl.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/ElementWrappingImplementation.dart
diff --git a/client/html/src/ElementWrappingImplementation.dart b/client/html/src/ElementWrappingImplementation.dart
index 38b82dff028c94a10426cd2c1c21c7c9095387d1..a10b510fb39e63c0527ff1aa4a16d585c90a7799 100644
--- a/client/html/src/ElementWrappingImplementation.dart
+++ b/client/html/src/ElementWrappingImplementation.dart
@@ -24,29 +24,11 @@ class _ChildrenElementList implements ElementList {
return LevelDom.wrapElement(_element.firstElementChild);
}
- void forEach(void f(Element element)) {
- for (var element in _childElements) {
- f(LevelDom.wrapElement(element));
- }
- }
+ void forEach(void f(Element element)) => _toList().forEach(f);
- Collection map(f(Element element)) {
- List output = new List();
- forEach((Element element) {
- output.add(f(element));
- });
- return output;
- }
+ Collection map(f(Element element)) => _toList().map(f);
- Collection<Element> filter(bool f(Element element)) {
- List<Element> output = new List<Element>();
- forEach((Element element) {
- if (f(element)) {
- output.add(element);
- }
- });
- return output;
- }
+ Collection<Element> filter(bool f(Element element)) => _toList().filter(f);
bool every(bool f(Element element)) {
for(Element element in this) {
@@ -67,7 +49,7 @@ class _ChildrenElementList implements ElementList {
}
bool isEmpty() {
- return _element.firstElementChild !== null;
+ return _element.firstElementChild === null;
}
int get length() {
@@ -110,29 +92,25 @@ class _ChildrenElementList implements ElementList {
throw 'Not impl yet. todo(jacobr)';
}
- void setRange(int start, int length, List from, [int startFrom = 0]) {
- throw const NotImplementedException();
- }
+ void setRange(int start, int length, List from, [int startFrom = 0]) =>
+ Lists.setRange(this, start, length, from, startFrom);
- void removeRange(int start, int length) {
- throw const NotImplementedException();
- }
+ 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) {
- throw const NotImplementedException();
- }
+ List getRange(int start, int length) => Lists.getRange(this, start, length);
int indexOf(Element element, [int start = 0]) {
- return _Lists.indexOf(this, element, start, this.length);
+ return Lists.indexOf(this, element, start, this.length);
}
int lastIndexOf(Element 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/release/htmlimpl.dart ('k') | client/html/src/Lists.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698