| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library custom_element.test.custom_element_test; | 5 library custom_element.test.custom_element_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:custom_element/custom_element.dart'; | 9 import 'package:custom_element/custom_element.dart'; |
| 10 import 'package:unittest/html_config.dart'; | 10 import 'package:unittest/html_config.dart'; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 var xtag = null; | 31 var xtag = null; |
| 32 registerCustomElement('fancy-button', () => xtag = new FancyButton()); | 32 registerCustomElement('fancy-button', () => xtag = new FancyButton()); |
| 33 expect(xtag, isNotNull, reason: 'FancyButton was created'); | 33 expect(xtag, isNotNull, reason: 'FancyButton was created'); |
| 34 expect(element.xtag, xtag, reason: 'xtag pointer should be set'); | 34 expect(element.xtag, xtag, reason: 'xtag pointer should be set'); |
| 35 expect(xtag.host, element, reason: 'host pointer should be set'); | 35 expect(xtag.host, element, reason: 'host pointer should be set'); |
| 36 expect(xtag.lifecycle, ['created']); | 36 expect(xtag.lifecycle, ['created']); |
| 37 return new Future(() { | 37 return new Future(() { |
| 38 expect(xtag.lifecycle, ['created', 'inserted']); | 38 expect(xtag.lifecycle, ['created', 'inserted']); |
| 39 element.remove(); | 39 element.remove(); |
| 40 return new Future(() { | 40 // TODO(jmesserly): the extra future here is to give IE9 time to deliver |
| 41 // its event. This seems wrong. We'll probably need some cooperation |
| 42 // between Dart and the polyfill to coordinate the microtask event loop. |
| 43 return new Future(() => new Future(() { |
| 41 expect(xtag.lifecycle, ['created', 'inserted', 'removed']); | 44 expect(xtag.lifecycle, ['created', 'inserted', 'removed']); |
| 42 }); | 45 })); |
| 43 }); | 46 }); |
| 44 }); | 47 }); |
| 45 | 48 |
| 46 test('create a component in code', () { | 49 test('create a component in code', () { |
| 47 var element = createElement('super-button'); | 50 var element = createElement('super-button'); |
| 48 expect(element.xtag, element, reason: 'element not registered'); | 51 expect(element.xtag, element, reason: 'element not registered'); |
| 49 | 52 |
| 50 var xtag = null; | 53 var xtag = null; |
| 51 registerCustomElement('super-button', () => xtag = new FancyButton()); | 54 registerCustomElement('super-button', () => xtag = new FancyButton()); |
| 52 | 55 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 81 } | 84 } |
| 82 inserted() { | 85 inserted() { |
| 83 super.inserted(); | 86 super.inserted(); |
| 84 lifecycle.add('inserted'); | 87 lifecycle.add('inserted'); |
| 85 } | 88 } |
| 86 removed() { | 89 removed() { |
| 87 super.removed(); | 90 super.removed(); |
| 88 lifecycle.add('removed'); | 91 lifecycle.add('removed'); |
| 89 } | 92 } |
| 90 } | 93 } |
| OLD | NEW |