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

Unified Diff: lib/html/templates/html/impl/impl_Element.darttemplate

Issue 11169004: Add "contains" method to Collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed last illegal-access Created 8 years, 2 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
Index: lib/html/templates/html/impl/impl_Element.darttemplate
diff --git a/lib/html/templates/html/impl/impl_Element.darttemplate b/lib/html/templates/html/impl/impl_Element.darttemplate
index 6f752320501b4b58b42695a160de7e8cefe59e74..038f7f1197a3be5a40dfd81c12ff36422f0e6ebb 100644
--- a/lib/html/templates/html/impl/impl_Element.darttemplate
+++ b/lib/html/templates/html/impl/impl_Element.darttemplate
@@ -21,6 +21,13 @@ class _ChildrenElementList implements List {
return output;
}
+ bool contains(Element element) {
+ for (_ElementImpl child in _childElements) {
+ if (child == element) return true;
+ }
+ return false;
+ }
+
void forEach(void f(Element element)) {
for (_ElementImpl element in _childElements) {
f(element);
@@ -28,7 +35,7 @@ class _ChildrenElementList implements List {
}
List<Element> filter(bool f(Element element)) {
- final output = [];
+ final output = <Element>[];
forEach((Element element) {
if (f(element)) {
output.add(element);
@@ -159,6 +166,13 @@ class _FrozenElementList implements List {
return _nodeList[0];
}
+ bool contains(Element element) {
+ for (Element el in this) {
+ if (el == element) return true;
+ }
+ return false;
+ }
+
void forEach(void f(Element element)) {
for (Element el in this) {
f(el);
@@ -174,7 +188,7 @@ class _FrozenElementList implements List {
}
List<Element> filter(bool f(Element element)) {
- final out = [];
+ final out = <Element>[];
for (Element el in this) {
if (f(el)) out.add(el);
}
@@ -465,6 +479,8 @@ class _CssClassSet implements CSSClassSet {
// interface Iterable - END
// interface Collection - BEGIN
+ bool contains(String element) => _read().contains(element);
+
void forEach(void f(String element)) {
_read().forEach(f);
}
« no previous file with comments | « lib/html/templates/html/impl/impl_DocumentFragment.darttemplate ('k') | lib/html/templates/html/impl/impl_Node.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698