Chromium Code Reviews| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 expect(div.dataset.length, 2); | 80 expect(div.dataset.length, 2); |
| 81 expect(div.dataset.isEmpty, isFalse); | 81 expect(div.dataset.isEmpty, isFalse); |
| 82 | 82 |
| 83 expect(div.dataset.remove('foo'), 'foo-value'); | 83 expect(div.dataset.remove('foo'), 'foo-value'); |
| 84 expect(div.dataset.length, 1); | 84 expect(div.dataset.length, 1); |
| 85 expect(div.dataset.isEmpty, isFalse); | 85 expect(div.dataset.isEmpty, isFalse); |
| 86 | 86 |
| 87 div.dataset.clear(); | 87 div.dataset.clear(); |
| 88 expect(div.dataset.length, 0); | 88 expect(div.dataset.length, 0); |
| 89 expect(div.dataset.isEmpty, isTrue); | 89 expect(div.dataset.isEmpty, isTrue); |
| 90 | |
| 91 Element otherDiv = new Element.html( | |
| 92 '<div id="dataDiv" data-my-message="Hello World"></div>', | |
| 93 treeSanitizer: new UnhelpfulSanitizer()); | |
| 94 expect(otherDiv.dataset.containsKey('myMessage'), isTrue); | |
| 95 | |
| 96 Element anotherDiv = new Element.html( | |
| 97 '<div id="dataDiv" data-eggs="bacon"></div>', | |
| 98 treeSanitizer: new UnhelpfulSanitizer()); | |
| 99 expect(anotherDiv.dataset.containsKey('eggs'), isTrue); | |
| 90 }); | 100 }); |
| 91 } | 101 } |
| 102 | |
| 103 /** | |
| 104 * A sanitizer that doesn't actually do anything! Allows us to add custom | |
| 105 * attributes (and anything else). | |
| 106 */ | |
| 107 class UnhelpfulSanitizer implements NodeTreeSanitizer { | |
|
blois
2013/10/10 21:13:39
import utils.dart and use NullTreeSanitizer from t
| |
| 108 UnhelpfulSanitizer(); | |
| 109 void sanitizeTree(Node node) {} | |
| 110 } | |
| OLD | NEW |