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 Iterable map(f(Element element)) { | 64 List mappedBy(f(Element element)) { |
65 return IterableMixinWorkaround.map(this, f); | |
66 } | |
67 | |
68 List mappedBy(f(ELement element)) { | |
69 return IterableMixinWorkaround.mappedByList(this, f); | 65 return IterableMixinWorkaround.mappedByList(this, f); |
70 } | 66 } |
71 | 67 |
72 Iterable<Element> where(bool f(Element element)) { | 68 Iterable<Element> where(bool f(Element element)) { |
73 return IterableMixinWorkaround.where(this, f); | 69 return IterableMixinWorkaround.where(this, f); |
74 } | 70 } |
75 | 71 |
76 bool get isEmpty { | 72 bool get isEmpty { |
77 return _element.$dom_firstElementChild == null; | 73 return _element.$dom_firstElementChild == null; |
78 } | 74 } |
79 | 75 |
80 Iterable<Element> take(int n) { | 76 List<Element> take(int n) { |
81 return IterableMixinWorkaround.takeList(this, n); | 77 return IterableMixinWorkaround.takeList(this, n); |
82 } | 78 } |
83 | 79 |
84 Iterable<Element> takeWhile(bool test(Element value)) { | 80 Iterable<Element> takeWhile(bool test(Element value)) { |
85 return IterableMixinWorkaround.takeWhile(this, test); | 81 return IterableMixinWorkaround.takeWhile(this, test); |
86 } | 82 } |
87 | 83 |
88 Iterable<Element> skip(int n) { | 84 List<Element> skip(int n) { |
89 return IterableMixinWorkaround.skipList(this, n); | 85 return IterableMixinWorkaround.skipList(this, n); |
90 } | 86 } |
91 | 87 |
92 Iterable<Element> skipWhile(bool test(Element value)) { | 88 Iterable<Element> skipWhile(bool test(Element value)) { |
93 return IterableMixinWorkaround.skipWhile(this, test); | 89 return IterableMixinWorkaround.skipWhile(this, test); |
94 } | 90 } |
95 | 91 |
96 Element firstMatching(bool test(Element value), {Element orElse()}) { | 92 Element firstMatching(bool test(Element value), {Element orElse()}) { |
97 return IterableMixinWorkaround.firstMatching(this, test, orElse); | 93 return IterableMixinWorkaround.firstMatching(this, test, orElse); |
98 } | 94 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 void forEach(void f(Element element)) { | 267 void forEach(void f(Element element)) { |
272 for (Element el in this) { | 268 for (Element el in this) { |
273 f(el); | 269 f(el); |
274 } | 270 } |
275 } | 271 } |
276 | 272 |
277 String join([String separator]) { | 273 String join([String separator]) { |
278 return IterableMixinWorkaround.joinList(this, separator); | 274 return IterableMixinWorkaround.joinList(this, separator); |
279 } | 275 } |
280 | 276 |
281 Iterable map(f(Element element)) { | 277 List mappedBy(f(Element element)) { |
282 return IterableMixinWorkaround.map(this, f); | |
283 } | |
284 | |
285 List mappedBy(f(ELement element)) { | |
286 return IterableMixinWorkaround.mappedByList(this, f); | 278 return IterableMixinWorkaround.mappedByList(this, f); |
287 } | 279 } |
288 | 280 |
289 Iterable<Element> where(bool f(Element element)) { | 281 Iterable<Element> where(bool f(Element element)) { |
290 return IterableMixinWorkaround.where(this, f); | 282 return IterableMixinWorkaround.where(this, f); |
291 } | 283 } |
292 | 284 |
293 bool every(bool f(Element element)) { | 285 bool every(bool f(Element element)) { |
294 for(Element element in this) { | 286 for(Element element in this) { |
295 if (!f(element)) { | 287 if (!f(element)) { |
296 return false; | 288 return false; |
297 } | 289 } |
298 }; | 290 }; |
299 return true; | 291 return true; |
300 } | 292 } |
301 | 293 |
302 bool any(bool f(Element element)) { | 294 bool any(bool f(Element element)) { |
303 for(Element element in this) { | 295 for(Element element in this) { |
304 if (f(element)) { | 296 if (f(element)) { |
305 return true; | 297 return true; |
306 } | 298 } |
307 }; | 299 }; |
308 return false; | 300 return false; |
309 } | 301 } |
310 | 302 |
311 List<Element> toList() => new List<Element>.from(this); | 303 List<Element> toList() => new List<Element>.from(this); |
312 Set<Element> toSet() => new Set<Element>.from(this); | 304 Set<Element> toSet() => new Set<Element>.from(this); |
313 | 305 |
314 Iterable<Element> take(int n) { | 306 List<Element> take(int n) { |
315 return IterableMixinWorkaround.takeList(this, n); | 307 return IterableMixinWorkaround.takeList(this, n); |
316 } | 308 } |
317 | 309 |
318 Iterable<Element> takeWhile(bool test(Element value)) { | 310 Iterable<Element> takeWhile(bool test(Element value)) { |
319 return IterableMixinWorkaround.takeWhile(this, test); | 311 return IterableMixinWorkaround.takeWhile(this, test); |
320 } | 312 } |
321 | 313 |
322 Iterable<Element> skip(int n) { | 314 List<Element> skip(int n) { |
323 return IterableMixinWorkaround.skipList(this, n); | 315 return IterableMixinWorkaround.skipList(this, n); |
324 } | 316 } |
325 | 317 |
326 Iterable<Element> skipWhile(bool test(Element value)) { | 318 Iterable<Element> skipWhile(bool test(Element value)) { |
327 return IterableMixinWorkaround.skipWhile(this, test); | 319 return IterableMixinWorkaround.skipWhile(this, test); |
328 } | 320 } |
329 | 321 |
330 Element firstMatching(bool test(Element value), {Element orElse()}) { | 322 Element firstMatching(bool test(Element value), {Element orElse()}) { |
331 return IterableMixinWorkaround.firstMatching(this, test, orElse); | 323 return IterableMixinWorkaround.firstMatching(this, test, orElse); |
332 } | 324 } |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 $if DART2JS | 1040 $if DART2JS |
1049 // Optimization to improve performance until the dart2js compiler inlines this | 1041 // Optimization to improve performance until the dart2js compiler inlines this |
1050 // method. | 1042 // method. |
1051 static dynamic createElement_tag(String tag) => | 1043 static dynamic createElement_tag(String tag) => |
1052 JS('Element', 'document.createElement(#)', tag); | 1044 JS('Element', 'document.createElement(#)', tag); |
1053 $else | 1045 $else |
1054 static Element createElement_tag(String tag) => | 1046 static Element createElement_tag(String tag) => |
1055 document.$dom_createElement(tag); | 1047 document.$dom_createElement(tag); |
1056 $endif | 1048 $endif |
1057 } | 1049 } |
OLD | NEW |