OLD | NEW |
(Empty) | |
| 1 <sky> |
| 2 <script> |
| 3 import "../resources/third_party/unittest/unittest.dart"; |
| 4 import "../resources/unit.dart"; |
| 5 |
| 6 import "dart:sky"; |
| 7 |
| 8 class FooElement extends Element { |
| 9 FooElement() : super("foo"); |
| 10 |
| 11 attachedCallback() { |
| 12 ++attachedCallbackCount; |
| 13 } |
| 14 |
| 15 detachedCallback() { |
| 16 ++detachedCallbackCount; |
| 17 } |
| 18 |
| 19 attributeChangedCallback(String name, String oldValue, String newValue) { |
| 20 ++attributeChangedCallbackCount; |
| 21 } |
| 22 |
| 23 int attachedCallbackCount = 0; |
| 24 int detachedCallbackCount = 0; |
| 25 int attributeChangedCallbackCount = 0; |
| 26 } |
| 27 |
| 28 |
| 29 void main() { |
| 30 initUnit(); |
| 31 |
| 32 document.registerElement("foo", FooElement); |
| 33 |
| 34 test("callbacks should be called", () { |
| 35 Element sky = document.querySelector("sky"); |
| 36 FooElement foo = document.createElement("foo"); |
| 37 expect(foo.attachedCallbackCount, equals(0)); |
| 38 expect(foo.detachedCallbackCount, equals(0)); |
| 39 expect(foo.attributeChangedCallbackCount, equals(0)); |
| 40 sky.appendChild(foo); |
| 41 expect(foo.attachedCallbackCount, equals(1)); |
| 42 expect(foo.detachedCallbackCount, equals(0)); |
| 43 expect(foo.attributeChangedCallbackCount, equals(0)); |
| 44 foo.setAttribute("bar", "baz"); |
| 45 expect(foo.attachedCallbackCount, equals(1)); |
| 46 expect(foo.detachedCallbackCount, equals(0)); |
| 47 expect(foo.attributeChangedCallbackCount, equals(1)); |
| 48 foo.remove(); |
| 49 expect(foo.attachedCallbackCount, equals(1)); |
| 50 expect(foo.detachedCallbackCount, equals(1)); |
| 51 expect(foo.attributeChangedCallbackCount, equals(1)); |
| 52 }); |
| 53 } |
| 54 </script> |
| 55 </sky> |
OLD | NEW |