OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 |
| 3 <html> |
| 4 <body> |
| 5 <ol> |
| 6 <li>Google</li> |
| 7 <li>Wikipedia</li> |
| 8 <li>Reddit</li> |
| 9 <li class='news'>New York Times</li> |
| 10 <li>Hacker News</li> |
| 11 </ol> |
| 12 |
| 13 <script type="application/dart"> |
| 14 |
| 15 import 'dart:html'; |
| 16 |
| 17 void main() { |
| 18 var children = query('ol').children; |
| 19 |
| 20 |
| 21 // RemoveAt() |
| 22 assert(children[1].innerHtml == 'Wikipedia'); |
| 23 children.removeAt(1); |
| 24 assert(children[1].innerHtml == 'Reddit'); |
| 25 |
| 26 print(children.runtimeType); |
| 27 |
| 28 // removeLast() |
| 29 children.removeLast(); |
| 30 assert(children.last.innerHtml == 'New York Times'); |
| 31 |
| 32 var news = query('.news'); |
| 33 |
| 34 children.remove(news); |
| 35 assert(children.last.innerHtml == 'Reddit'); |
| 36 |
| 37 // BUG: RemoveWhere: does not work. retainWhere() also does not work. |
| 38 // children.removeWhere((child) => child.innerHtml.length == 5); |
| 39 |
| 40 children.clear(); |
| 41 assert(children.isEmpty); |
| 42 } |
| 43 |
| 44 </script> |
| 45 <script src="packages/browser/dart.js"></script> |
| 46 </body> |
| 47 </html> |
OLD | NEW |