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

Unified Diff: recipes/web/html/removing_children.html

Issue 14109034: Recipes for using CSS Selectors with dart:html (Closed) Base URL: https://github.com/dart-lang/cookbook.git@master
Patch Set: Removed unwanted file. Created 7 years, 8 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: recipes/web/html/removing_children.html
diff --git a/recipes/web/html/removing_children.html b/recipes/web/html/removing_children.html
new file mode 100644
index 0000000000000000000000000000000000000000..60d2a57f5faef079f4e2cb6cd4d83607376404cf
--- /dev/null
+++ b/recipes/web/html/removing_children.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+
+<html>
+ <body>
+ <ol>
+ <li>Google</li>
+ <li>Wikipedia</li>
+ <li>Reddit</li>
+ <li class='news'>New York Times</li>
+ <li>Hacker News</li>
+ </ol>
+
+ <script type="application/dart">
+
+ import 'dart:html';
+
+ void main() {
+ var children = query('ol').children;
+
+
+ // RemoveAt()
+ assert(children[1].innerHtml == 'Wikipedia');
+ children.removeAt(1);
+ assert(children[1].innerHtml == 'Reddit');
+
+ print(children.runtimeType);
+
+ // removeLast()
+ children.removeLast();
+ assert(children.last.innerHtml == 'New York Times');
+
+ var news = query('.news');
+
+ children.remove(news);
+ assert(children.last.innerHtml == 'Reddit');
+
+ // BUG: RemoveWhere: does not work. retainWhere() also does not work.
+ // children.removeWhere((child) => child.innerHtml.length == 5);
+
+ children.clear();
+ assert(children.isEmpty);
+ }
+
+ </script>
+ <script src="packages/browser/dart.js"></script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698