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

Unified Diff: sdk/lib/html/html_common/filtered_element_list.dart

Issue 1129333002: Indices passed to FilteredElementList public functions should consistently refer to element indices (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Test cases and patch for Dart issue 23418 Created 5 years, 7 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 | « no previous file | tests/html/filteredelementlist_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/html_common/filtered_element_list.dart
diff --git a/sdk/lib/html/html_common/filtered_element_list.dart b/sdk/lib/html/html_common/filtered_element_list.dart
index 3514cdc654135ce42502eb59c6f95fe81e9a0355..242da062ca615ee136ab7f6577f99b6aeb35487c 100644
--- a/sdk/lib/html/html_common/filtered_element_list.dart
+++ b/sdk/lib/html/html_common/filtered_element_list.dart
@@ -28,8 +28,8 @@ class FilteredElementList<T extends Element> extends ListBase<T>
//
// TODO(nweiz): we don't always need to create a new list. For example
// forEach, every, any, ... could directly work on the _childNodes.
- List<T> get _filtered =>
- new List<T>.from(_childNodes.where((n) => n is Element));
+ Iterable<T> get _iterable => _childNodes.where((n) => n is Element);
+ List<T> get _filtered => new List<T>.from(_iterable, growable: false);
void forEach(void f(T element)) {
_filtered.forEach(f);
@@ -104,11 +104,13 @@ class FilteredElementList<T extends Element> extends ListBase<T>
}
void insert(int index, T value) {
- _childNodes.insert(index, value);
+ Element element =_iterable.elementAt(index);
+ element.parentNode.insertBefore(value, element);
}
void insertAll(int index, Iterable<T> iterable) {
- _childNodes.insertAll(index, iterable);
+ Element element =_iterable.elementAt(index);
+ element.parentNode.insertAllBefore(iterable, element);
}
T removeAt(int index) {
« no previous file with comments | « no previous file | tests/html/filteredelementlist_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698