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

Side by Side 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: Removed unwanted file. 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2
3 <html>
4 <body>
5 <h2>Business plan</h2>
6 <ul>
7 <li>Get crazy startup idea</li>
8 <li>Set up company
9 <ul>
10 <li>Build something</li>
11 <li>Raise money</li>
12 <li>Get users</li>
13 </ul>
14 <li>Buy private jet!</li>
15 </ul>
16
17 <p><a href='#'>Change to ordered list</a></p>
18
19 <script type="application/dart">
20
21 import 'dart:html';
22
23 void changeToOrderedList(items) {
24 items.forEach((item) {
25 var ol = new Element.tag('ol');
26 ol.children.addAll(item.children);
27 item.replaceWith(ol);
28 });
29 }
30
31 void main() {
32 var link = query('a');
33 link.onClick.listen((event) {
34 changeToOrderedList(queryAll('ul'));
35 event.preventDefault();
36 event.stopPropagation();
37 event.target.replaceWith(new Element.html('<p>Done!</p>'));
38 });
39 }
40 </script>
41
42 <script src="packages/browser/dart.js"></script>
43 </body>
44 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698