| OLD | NEW |
| 1 library ElementTest; | 1 library ElementTest; |
| 2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
| 3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_config.dart'; |
| 4 import 'dart:html'; | 4 import 'dart:html'; |
| 5 | 5 |
| 6 main() { | 6 main() { |
| 7 useHtmlConfiguration(); | 7 useHtmlConfiguration(); |
| 8 test('InnerHTML', () { | 8 test('InnerHTML', () { |
| 9 Element element = new Element.tag('div'); | 9 Element element = new Element.tag('div'); |
| 10 element.id = 'test'; | 10 element.id = 'test'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 table.nodes.add(row); | 22 table.nodes.add(row); |
| 23 | 23 |
| 24 row.nodes.add(new Element.tag('td')); | 24 row.nodes.add(new Element.tag('td')); |
| 25 row.nodes.add(new Element.tag('td')); | 25 row.nodes.add(new Element.tag('td')); |
| 26 | 26 |
| 27 expect(row.cells.length, 2); | 27 expect(row.cells.length, 2); |
| 28 | 28 |
| 29 TableRowElement headerRow = table.rows[0]; | 29 TableRowElement headerRow = table.rows[0]; |
| 30 expect(headerRow.cells.length, 2); | 30 expect(headerRow.cells.length, 2); |
| 31 }); | 31 }); |
| 32 test('dataAttributes', () { | 32 test('dataset', () { |
| 33 Element div = new Element.tag('div'); | 33 Element div = new Element.tag('div'); |
| 34 | 34 |
| 35 expect(div.dataAttributes.isEmpty, isTrue); | 35 expect(div.dataset.isEmpty, isTrue); |
| 36 expect(div.dataAttributes['foo'], isNull); | 36 expect(div.dataset['foo'], isNull); |
| 37 expect(div.dataAttributes.isEmpty, isTrue); | 37 expect(div.dataset.isEmpty, isTrue); |
| 38 | 38 |
| 39 div.dataAttributes['foo'] = 'foo-value'; | 39 div.dataset['foo'] = 'foo-value'; |
| 40 expect(div.dataAttributes['foo'], 'foo-value'); | 40 expect(div.dataset['foo'], 'foo-value'); |
| 41 expect(div.dataAttributes.isEmpty, isFalse); | 41 expect(div.dataset.isEmpty, isFalse); |
| 42 | 42 |
| 43 expect(div.dataAttributes.containsValue('foo-value'), isTrue); | 43 expect(div.dataset.containsValue('foo-value'), isTrue); |
| 44 expect(div.dataAttributes.containsValue('bar-value'), isFalse); | 44 expect(div.dataset.containsValue('bar-value'), isFalse); |
| 45 expect(div.dataAttributes.containsKey('foo'), isTrue); | 45 expect(div.dataset.containsKey('foo'), isTrue); |
| 46 expect(div.dataAttributes.containsKey('bar'), isFalse); | 46 expect(div.dataset.containsKey('bar'), isFalse); |
| 47 | 47 |
| 48 bool hasBeenInvoked; | 48 bool hasBeenInvoked; |
| 49 String f() { | 49 String f() { |
| 50 hasBeenInvoked = true; | 50 hasBeenInvoked = true; |
| 51 return 'bar-value'; | 51 return 'bar-value'; |
| 52 } | 52 } |
| 53 | 53 |
| 54 hasBeenInvoked = false; | 54 hasBeenInvoked = false; |
| 55 expect(div.dataAttributes.putIfAbsent('bar', f), 'bar-value'); | 55 expect(div.dataset.putIfAbsent('bar', f), 'bar-value'); |
| 56 expect(hasBeenInvoked, isTrue); | 56 expect(hasBeenInvoked, isTrue); |
| 57 | 57 |
| 58 hasBeenInvoked = false; | 58 hasBeenInvoked = false; |
| 59 expect(div.dataAttributes.putIfAbsent('bar', f), 'bar-value'); | 59 expect(div.dataset.putIfAbsent('bar', f), 'bar-value'); |
| 60 expect(hasBeenInvoked, isFalse); | 60 expect(hasBeenInvoked, isFalse); |
| 61 | 61 |
| 62 final keys = <String> []; | 62 final keys = <String> []; |
| 63 final values = <String> []; | 63 final values = <String> []; |
| 64 div.dataAttributes.forEach((String key, String value) { | 64 div.dataset.forEach((String key, String value) { |
| 65 keys.add(key); | 65 keys.add(key); |
| 66 values.add(value); | 66 values.add(value); |
| 67 }); | 67 }); |
| 68 expect(keys, unorderedEquals(['foo', 'bar'])); | 68 expect(keys, unorderedEquals(['foo', 'bar'])); |
| 69 expect(values, unorderedEquals(['foo-value', 'bar-value'])); | 69 expect(values, unorderedEquals(['foo-value', 'bar-value'])); |
| 70 | 70 |
| 71 expect(new List<String>.from(div.dataAttributes.keys), | 71 expect(new List<String>.from(div.dataset.keys), |
| 72 unorderedEquals(['foo', 'bar'])); | 72 unorderedEquals(['foo', 'bar'])); |
| 73 expect(new List<String>.from(div.dataAttributes.values), | 73 expect(new List<String>.from(div.dataset.values), |
| 74 unorderedEquals(['foo-value', 'bar-value'])); | 74 unorderedEquals(['foo-value', 'bar-value'])); |
| 75 | 75 |
| 76 expect(div.dataAttributes.length, 2); | 76 expect(div.dataset.length, 2); |
| 77 expect(div.dataAttributes.isEmpty, isFalse); | 77 expect(div.dataset.isEmpty, isFalse); |
| 78 | 78 |
| 79 expect(div.dataAttributes.remove('qux'), isNull); | 79 expect(div.dataset.remove('qux'), isNull); |
| 80 expect(div.dataAttributes.length, 2); | 80 expect(div.dataset.length, 2); |
| 81 expect(div.dataAttributes.isEmpty, isFalse); | 81 expect(div.dataset.isEmpty, isFalse); |
| 82 | 82 |
| 83 expect(div.dataAttributes.remove('foo'), 'foo-value'); | 83 expect(div.dataset.remove('foo'), 'foo-value'); |
| 84 expect(div.dataAttributes.length, 1); | 84 expect(div.dataset.length, 1); |
| 85 expect(div.dataAttributes.isEmpty, isFalse); | 85 expect(div.dataset.isEmpty, isFalse); |
| 86 | 86 |
| 87 div.dataAttributes.clear(); | 87 div.dataset.clear(); |
| 88 expect(div.dataAttributes.length, 0); | 88 expect(div.dataset.length, 0); |
| 89 expect(div.dataAttributes.isEmpty, isTrue); | 89 expect(div.dataset.isEmpty, isTrue); |
| 90 }); | 90 }); |
| 91 } | 91 } |
| OLD | NEW |