| 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/boot.js"></script> | 10 <script src="packages/polymer/boot.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 <polymer-element name="test-a" on-click="clickHandler"> | 22 <polymer-element name="test-a" on-click="clickHandler"> |
| 23 <template></template> | 23 <template></template> |
| 24 <script type="application/dart"> | 24 <script type="application/dart"> |
| 25 import 'package:polymer/polymer.dart'; | 25 import 'package:polymer/polymer.dart'; |
| 26 | 26 |
| 27 @CustomTag("test-a") | 27 @CustomTag("test-a") |
| 28 class TestA extends PolymerElement { | 28 class TestA extends PolymerElement { |
| 29 TestA.created() : super.created(); |
| 30 |
| 29 List clicks = []; | 31 List clicks = []; |
| 30 void clickHandler() { | 32 void clickHandler() { |
| 31 clicks.add('host click on: $localName (id $id)'); | 33 clicks.add('host click on: $localName (id $id)'); |
| 32 } | 34 } |
| 33 } | 35 } |
| 34 </script> | 36 </script> |
| 35 </polymer-element> | 37 </polymer-element> |
| 36 | 38 |
| 37 <polymer-element name="test-b"> | 39 <polymer-element name="test-b"> |
| 38 <template> | 40 <template> |
| 39 <div> | 41 <div> |
| 40 <span id="b-1">1</span> | 42 <span id="b-1">1</span> |
| 41 <span id="b-2" on-click="clickHandler">2</span> | 43 <span id="b-2" on-click="clickHandler">2</span> |
| 42 </div> | 44 </div> |
| 43 </template> | 45 </template> |
| 44 <script type="application/dart"> | 46 <script type="application/dart"> |
| 45 import 'package:polymer/polymer.dart'; | 47 import 'package:polymer/polymer.dart'; |
| 46 | 48 |
| 47 @CustomTag("test-b") | 49 @CustomTag("test-b") |
| 48 class TestB extends PolymerElement { | 50 class TestB extends PolymerElement { |
| 51 TestB.created() : super.created(); |
| 52 |
| 49 List clicks = []; | 53 List clicks = []; |
| 50 void clickHandler(event, detail, target) { | 54 void clickHandler(event, detail, target) { |
| 51 clicks.add('local click under $localName (id $id) on ${target.id}'); | 55 clicks.add('local click under $localName (id $id) on ${target.id}'); |
| 52 } | 56 } |
| 53 } | 57 } |
| 54 </script> | 58 </script> |
| 55 </polymer-element> | 59 </polymer-element> |
| 56 | 60 |
| 57 <test-a id="a"></test-a> | 61 <test-a id="a"></test-a> |
| 58 <test-b id="b"></test-b> | 62 <test-b id="b"></test-b> |
| 59 | 63 |
| 60 <script type="application/dart" src="events_test.dart"></script> | 64 <script type="application/dart" src="events_test.dart"></script> |
| 61 </body> | 65 </body> |
| 62 </html> | 66 </html> |
| OLD | NEW |