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

Unified Diff: recipes/web/html/replacing_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: Changes based on Kathy's comments. Created 7 years, 7 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
« no previous file with comments | « recipes/web/html/replacing.html ('k') | recipes/web/html/scoped_selectors.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipes/web/html/replacing_children.html
diff --git a/recipes/web/html/replacing_children.html b/recipes/web/html/replacing_children.html
new file mode 100644
index 0000000000000000000000000000000000000000..de2873983fc2a64892005a3777846f0520673421
--- /dev/null
+++ b/recipes/web/html/replacing_children.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+
+<html>
+ <body>
+ <h2>Business plan</h2>
+ <ul>
+ <li>Get crazy startup idea</li>
+ <li>Set up company
+ <ul>
+ <li>Build something</li>
+ <li>Raise money</li>
+ <li>Get users</li>
+ </ul>
+ <li>Buy private jet!</li>
+ </ul>
+
+ <p><a href='#'>Change to ordered list</a></p>
+
+ <script type="application/dart">
+
+ import 'dart:html';
+
+ void changeToOrderedList(items) {
+ items.forEach((item) {
+ var ol = new Element.tag('ol');
+ ol.children.addAll(item.children);
+ item.replaceWith(ol);
+ });
+ }
+
+ void main() {
+ var link = query('a');
+ link.onClick.listen((event) {
+ changeToOrderedList(queryAll('ul'));
+ event.preventDefault();
+ event.stopPropagation();
+ event.target.replaceWith(new Element.html('<p>Done!</p>'));
+ });
+ }
+ </script>
+
+ <script src="packages/browser/dart.js"></script>
+ </body>
+</html>
« no previous file with comments | « recipes/web/html/replacing.html ('k') | recipes/web/html/scoped_selectors.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698