OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of html; | 5 part of html; |
6 | 6 |
7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated | 7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated |
8 // functionality. | 8 // functionality. |
9 class _ChildrenElementList implements List { | 9 class _ChildrenElementList implements List { |
10 // Raw Element. | 10 // Raw Element. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 return true; | 54 return true; |
55 } | 55 } |
56 } | 56 } |
57 return false; | 57 return false; |
58 } | 58 } |
59 | 59 |
60 String join([String separator]) { | 60 String join([String separator]) { |
61 return IterableMixinWorkaround.joinList(this, separator); | 61 return IterableMixinWorkaround.joinList(this, separator); |
62 } | 62 } |
63 | 63 |
64 List mappedBy(f(Element element)) { | 64 Iterable map(f(Element element)) { |
| 65 return IterableMixinWorkaround.map(this, f); |
| 66 } |
| 67 |
| 68 List mappedBy(f(ELement element)) { |
65 return IterableMixinWorkaround.mappedByList(this, f); | 69 return IterableMixinWorkaround.mappedByList(this, f); |
66 } | 70 } |
67 | 71 |
68 Iterable<Element> where(bool f(Element element)) { | 72 Iterable<Element> where(bool f(Element element)) { |
69 return IterableMixinWorkaround.where(this, f); | 73 return IterableMixinWorkaround.where(this, f); |
70 } | 74 } |
71 | 75 |
72 bool get isEmpty { | 76 bool get isEmpty { |
73 return _element.$dom_firstElementChild == null; | 77 return _element.$dom_firstElementChild == null; |
74 } | 78 } |
75 | 79 |
76 List<Element> take(int n) { | 80 Iterable<Element> take(int n) { |
77 return IterableMixinWorkaround.takeList(this, n); | 81 return IterableMixinWorkaround.takeList(this, n); |
78 } | 82 } |
79 | 83 |
80 Iterable<Element> takeWhile(bool test(Element value)) { | 84 Iterable<Element> takeWhile(bool test(Element value)) { |
81 return IterableMixinWorkaround.takeWhile(this, test); | 85 return IterableMixinWorkaround.takeWhile(this, test); |
82 } | 86 } |
83 | 87 |
84 List<Element> skip(int n) { | 88 Iterable<Element> skip(int n) { |
85 return IterableMixinWorkaround.skipList(this, n); | 89 return IterableMixinWorkaround.skipList(this, n); |
86 } | 90 } |
87 | 91 |
88 Iterable<Element> skipWhile(bool test(Element value)) { | 92 Iterable<Element> skipWhile(bool test(Element value)) { |
89 return IterableMixinWorkaround.skipWhile(this, test); | 93 return IterableMixinWorkaround.skipWhile(this, test); |
90 } | 94 } |
91 | 95 |
92 Element firstMatching(bool test(Element value), {Element orElse()}) { | 96 Element firstMatching(bool test(Element value), {Element orElse()}) { |
93 return IterableMixinWorkaround.firstMatching(this, test, orElse); | 97 return IterableMixinWorkaround.firstMatching(this, test, orElse); |
94 } | 98 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 void forEach(void f(Element element)) { | 271 void forEach(void f(Element element)) { |
268 for (Element el in this) { | 272 for (Element el in this) { |
269 f(el); | 273 f(el); |
270 } | 274 } |
271 } | 275 } |
272 | 276 |
273 String join([String separator]) { | 277 String join([String separator]) { |
274 return IterableMixinWorkaround.joinList(this, separator); | 278 return IterableMixinWorkaround.joinList(this, separator); |
275 } | 279 } |
276 | 280 |
277 List mappedBy(f(Element element)) { | 281 Iterable map(f(Element element)) { |
| 282 return IterableMixinWorkaround.map(this, f); |
| 283 } |
| 284 |
| 285 List mappedBy(f(ELement element)) { |
278 return IterableMixinWorkaround.mappedByList(this, f); | 286 return IterableMixinWorkaround.mappedByList(this, f); |
279 } | 287 } |
280 | 288 |
281 Iterable<Element> where(bool f(Element element)) { | 289 Iterable<Element> where(bool f(Element element)) { |
282 return IterableMixinWorkaround.where(this, f); | 290 return IterableMixinWorkaround.where(this, f); |
283 } | 291 } |
284 | 292 |
285 bool every(bool f(Element element)) { | 293 bool every(bool f(Element element)) { |
286 for(Element element in this) { | 294 for(Element element in this) { |
287 if (!f(element)) { | 295 if (!f(element)) { |
288 return false; | 296 return false; |
289 } | 297 } |
290 }; | 298 }; |
291 return true; | 299 return true; |
292 } | 300 } |
293 | 301 |
294 bool any(bool f(Element element)) { | 302 bool any(bool f(Element element)) { |
295 for(Element element in this) { | 303 for(Element element in this) { |
296 if (f(element)) { | 304 if (f(element)) { |
297 return true; | 305 return true; |
298 } | 306 } |
299 }; | 307 }; |
300 return false; | 308 return false; |
301 } | 309 } |
302 | 310 |
303 List<Element> toList() => new List<Element>.from(this); | 311 List<Element> toList() => new List<Element>.from(this); |
304 Set<Element> toSet() => new Set<Element>.from(this); | 312 Set<Element> toSet() => new Set<Element>.from(this); |
305 | 313 |
306 List<Element> take(int n) { | 314 Iterable<Element> take(int n) { |
307 return IterableMixinWorkaround.takeList(this, n); | 315 return IterableMixinWorkaround.takeList(this, n); |
308 } | 316 } |
309 | 317 |
310 Iterable<Element> takeWhile(bool test(Element value)) { | 318 Iterable<Element> takeWhile(bool test(Element value)) { |
311 return IterableMixinWorkaround.takeWhile(this, test); | 319 return IterableMixinWorkaround.takeWhile(this, test); |
312 } | 320 } |
313 | 321 |
314 List<Element> skip(int n) { | 322 Iterable<Element> skip(int n) { |
315 return IterableMixinWorkaround.skipList(this, n); | 323 return IterableMixinWorkaround.skipList(this, n); |
316 } | 324 } |
317 | 325 |
318 Iterable<Element> skipWhile(bool test(Element value)) { | 326 Iterable<Element> skipWhile(bool test(Element value)) { |
319 return IterableMixinWorkaround.skipWhile(this, test); | 327 return IterableMixinWorkaround.skipWhile(this, test); |
320 } | 328 } |
321 | 329 |
322 Element firstMatching(bool test(Element value), {Element orElse()}) { | 330 Element firstMatching(bool test(Element value), {Element orElse()}) { |
323 return IterableMixinWorkaround.firstMatching(this, test, orElse); | 331 return IterableMixinWorkaround.firstMatching(this, test, orElse); |
324 } | 332 } |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 $if DART2JS | 1048 $if DART2JS |
1041 // Optimization to improve performance until the dart2js compiler inlines this | 1049 // Optimization to improve performance until the dart2js compiler inlines this |
1042 // method. | 1050 // method. |
1043 static dynamic createElement_tag(String tag) => | 1051 static dynamic createElement_tag(String tag) => |
1044 JS('Element', 'document.createElement(#)', tag); | 1052 JS('Element', 'document.createElement(#)', tag); |
1045 $else | 1053 $else |
1046 static Element createElement_tag(String tag) => | 1054 static Element createElement_tag(String tag) => |
1047 document.$dom_createElement(tag); | 1055 document.$dom_createElement(tag); |
1048 $endif | 1056 $endif |
1049 } | 1057 } |
OLD | NEW |