| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 for details. All rights reserved. Use of this source code is governed by a | 4 for details. All rights reserved. Use of this source code is governed by a |
| 5 BSD-style license that can be found in the LICENSE file. | 5 BSD-style license that can be found in the LICENSE file. |
| 6 --> | 6 --> |
| 7 <html> | 7 <html> |
| 8 <head> | 8 <head> |
| 9 <title>event path</title> | 9 <title>event path</title> |
| 10 <script src="packages/polymer/testing/testing.js"></script> | 10 <script src="packages/polymer/testing/testing.js"></script> |
| 11 <script src="packages/unittest/test_controller.js"></script> | 11 <script src="packages/unittest/test_controller.js"></script> |
| 12 <!-- | 12 <!-- |
| 13 Test ported from: | 13 Test ported from: |
| 14 https://github.com/Polymer/polymer/blob/7936ff8/test/js/events.js | 14 https://github.com/Polymer/polymer/blob/7936ff8/test/js/events.js |
| 15 | 15 |
| 16 TODO(sigmund): when we have support for mutation observers, render all of | 16 TODO(sigmund): when we have support for mutation observers, render all of |
| 17 the test in Dart (like events.js does in JS) | 17 the test in Dart (like events.js does in JS) |
| 18 --> | 18 --> |
| 19 </head> | 19 </head> |
| 20 <body> | 20 <body> |
| 21 | 21 |
| 22 <!-- TODO(sigmund): use <polymer-element>, not <element> --> | 22 <polymer-element name="test-a" on-click="clickHandler"> |
| 23 <element name="test-a" on-click="clickHandler"> | |
| 24 <template></template> | 23 <template></template> |
| 25 <script type="application/dart"> | 24 <script type="application/dart"> |
| 26 import 'package:polymer/polymer.dart'; | 25 import 'package:polymer/polymer.dart'; |
| 27 | 26 |
| 28 class TestA extends PolymerElement { | 27 class TestA extends PolymerElement { |
| 29 List clicks = []; | 28 List clicks = []; |
| 30 void clickHandler() { | 29 void clickHandler() { |
| 31 clicks.add('host click on: $localName (id $id)'); | 30 clicks.add('host click on: $localName (id $id)'); |
| 32 } | 31 } |
| 33 } | 32 } |
| 34 </script> | 33 </script> |
| 35 </element> | 34 </polymer-element> |
| 36 | 35 |
| 37 <element name="test-b"> | 36 <polymer-element name="test-b"> |
| 38 <template> | 37 <template> |
| 39 <div> | 38 <div> |
| 40 <span id="b-1">1</span> | 39 <span id="b-1">1</span> |
| 41 <span id="b-2" on-click="clickHandler">2</span> | 40 <span id="b-2" on-click="clickHandler">2</span> |
| 42 </div> | 41 </div> |
| 43 </template> | 42 </template> |
| 44 <script type="application/dart"> | 43 <script type="application/dart"> |
| 45 import 'package:polymer/polymer.dart'; | 44 import 'package:polymer/polymer.dart'; |
| 46 | 45 |
| 47 class TestB extends PolymerElement { | 46 class TestB extends PolymerElement { |
| 48 List clicks = []; | 47 List clicks = []; |
| 49 void clickHandler(event, detail, target) { | 48 void clickHandler(event, detail, target) { |
| 50 clicks.add('local click under $localName (id $id) on ${target.id}'); | 49 clicks.add('local click under $localName (id $id) on ${target.id}'); |
| 51 } | 50 } |
| 52 } | 51 } |
| 53 </script> | 52 </script> |
| 54 </element> | 53 </polymer-element> |
| 55 | 54 |
| 56 <test-a id="a"></test-a> | 55 <test-a id="a"></test-a> |
| 57 <test-b id="b"></test-b> | 56 <test-b id="b"></test-b> |
| 58 | 57 |
| 59 <script type="application/dart"> | 58 <script type="application/dart"> |
| 60 import 'dart:html'; | 59 import 'dart:html'; |
| 61 import 'dart:async'; | 60 import 'dart:async'; |
| 62 import 'package:unittest/unittest.dart'; | 61 import 'package:unittest/unittest.dart'; |
| 63 import 'package:unittest/html_config.dart'; | 62 import 'package:unittest/html_config.dart'; |
| 64 | 63 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 87 expect(testB.xtag.clicks, []); | 86 expect(testB.xtag.clicks, []); |
| 88 var b2 = testB.shadowRoot.query('#b-2'); | 87 var b2 = testB.shadowRoot.query('#b-2'); |
| 89 b2.click(); | 88 b2.click(); |
| 90 expect(testB.xtag.clicks, ['local click under span (id b) on b-2']); | 89 expect(testB.xtag.clicks, ['local click under span (id b) on b-2']); |
| 91 })); | 90 })); |
| 92 }); | 91 }); |
| 93 } | 92 } |
| 94 </script> | 93 </script> |
| 95 </body> | 94 </body> |
| 96 </html> | 95 </html> |
| OLD | NEW |