OLD | NEW |
1 import 'dart:html'; | 1 import 'dart:html'; |
2 | 2 |
3 import 'package:expect/minitest.dart'; | 3 import 'package:expect/minitest.dart'; |
4 | 4 |
5 main() { | 5 main() { |
6 var isStyleSheetList = | 6 var isStyleSheetList = |
7 predicate((x) => x is List<StyleSheet>, 'is a List<StyleSheet>'); | 7 predicate((x) => x is List<StyleSheet>, 'is a List<StyleSheet>'); |
8 | 8 |
9 test('NodeList', () { | 9 test('NodeList', () { |
10 List<Node> asList = window.document.queryAll('body'); | 10 List<Element> asList = window.document.queryAll('body'); |
11 // Check it's Iterable | 11 // Check it's Iterable |
12 int counter = 0; | 12 int counter = 0; |
13 for (Node node in window.document.queryAll('body')) { | 13 for (Element node in window.document.queryAll('body')) { |
14 counter++; | 14 counter++; |
15 } | 15 } |
16 expect(counter, 1); | 16 expect(counter, 1); |
17 counter = 0; | 17 counter = 0; |
18 window.document.queryAll('body').forEach((e) { counter++; }); | 18 window.document.queryAll('body').forEach((e) { counter++; }); |
19 expect(counter, 1); | 19 expect(counter, 1); |
20 }); | 20 }); |
21 | 21 |
22 test('StyleSheetList', () { | 22 test('StyleSheetList', () { |
23 var document = window.document as HtmlDocument; | 23 var document = window.document as HtmlDocument; |
24 List<StyleSheet> asList = document.styleSheets; | 24 List<StyleSheet> asList = document.styleSheets; |
25 expect(asList, isStyleSheetList); | 25 expect(asList, isStyleSheetList); |
26 // Check it's Iterable. | 26 // Check it's Iterable. |
27 int counter = 0; | 27 int counter = 0; |
28 for (StyleSheet styleSheet in document.styleSheets) { | 28 for (StyleSheet styleSheet in document.styleSheets) { |
29 counter++; | 29 counter++; |
30 } | 30 } |
31 | 31 |
32 // There are no style sheets. | 32 // There are no style sheets. |
33 expect(counter, 0); | 33 expect(counter, 0); |
34 }); | 34 }); |
35 } | 35 } |
OLD | NEW |