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

Side by Side Diff: recipes/web/html/selectors_hierarchy.html

Issue 14109034: Recipes for using CSS Selectors with dart:html (Closed) Base URL: https://github.com/dart-lang/cookbook.git@master
Patch Set: Incorporated changes recommended by Seth 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 <head>
5 <title>selectors_hierarchy</title>
6 </head>
7
8 <body>
9 <ul>
10 <li id='first'>Item 1</li>
11 <li>Item 2
12 <ul>
13 <li>Nested Item 1</li>
14 <li>Nested Item 2</li>
15 </ul>
16 </li>
17 <li>Item 3</li>
18 </ul>
19
20 <script type="application/dart">
21
22 import 'dart:html';
23
24 void main() {
25
26 // Child elements.
27 List<Element> elements = queryAll('li > ul');
28 assert(elements.length == 1);
29
30 // Descendant elements.
31 elements = queryAll('li li');
32 assert(elements.length == 2);
33
34
35 // Next adjacent selectors.
36 elements = queryAll('#first + li');
37 assert(elements.length == 1);
38 elements.forEach((el) => el.style.color = 'red');
39
40 // Next adjacent selectors.
41 elements = queryAll('#first ~ li');
42 assert(elements.length == 2);
43 elements.forEach((el) => el.style.textDecoration = 'underline');
44 }
45
46 </script>
47 <script src="packages/browser/dart.js"></script>
48 </body>
49 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698