OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 Copyright (c) 2012, 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 lang="en"> | 7 <html lang="en"> |
8 <head> | 8 <head> |
9 <meta charset="utf-8"> | 9 <meta charset="utf-8"> |
10 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | 10 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
11 <title>watch_global_var_test</title> | 11 <title>watch_global_var_test</title> |
12 <script type='application/javascript' src="testing.js"></script> | 12 <script type='application/javascript' src="testing.js"></script> |
13 </head> | 13 </head> |
14 <body> | 14 <body> |
| 15 <element name="x-my-input" extends="input"> |
| 16 <template></template> |
| 17 <script type="application/dart"> |
| 18 import 'package:web_components/web_components.dart'; |
| 19 class MyInput extends WebComponent { |
| 20 int clicked; |
| 21 created() { |
| 22 clicked = 0; |
| 23 } |
| 24 inserted() { |
| 25 on.click.add((e) { clicked++; }); |
| 26 } |
| 27 } |
| 28 </script> |
| 29 </element> |
15 <form> | 30 <form> |
16 <input name="a" type="radio" value="Foo" bind-value="name">Foo! | 31 <!-- TODO(jmesserly): if fix #82 we can use <x-my-input> tags. --> |
17 <input name="a" type="radio" value="Bar" bind-value="name">Bar! | 32 <input is="x-my-input" name="a" type="radio" value="Foo" bind-value="name"> |
| 33 Foo! |
| 34 <input is="x-my-input" name="a" type="radio" value="Bar" bind-value="name"> |
| 35 Bar! |
18 </form> | 36 </form> |
19 <pre>You picked {{name}}. Final value should be 'Bar'</pre> | 37 <pre>You picked {{name}}. Final value should be 'Bar'</pre> |
20 <script type="application/dart"> | 38 <script type="application/dart"> |
21 import 'dart:html'; | 39 import 'dart:html'; |
22 import 'package:web_components/web_components.dart'; | 40 import 'package:web_components/web_components.dart'; |
23 import 'package:unittest/unittest.dart'; | 41 import 'package:unittest/unittest.dart'; |
24 | 42 |
25 var name = 'Bar'; | 43 var name = 'Bar'; |
26 var foo = queryAll('input')[0]; | 44 var foo = queryAll('input')[0]; |
27 var bar = queryAll('input')[1]; | 45 var bar = queryAll('input')[1]; |
(...skipping 14 matching lines...) Expand all Loading... |
42 expect(foo.checked, false, reason: 'nothing picked.'); | 60 expect(foo.checked, false, reason: 'nothing picked.'); |
43 expect(bar.checked, false, reason: 'nothing picked.'); | 61 expect(bar.checked, false, reason: 'nothing picked.'); |
44 expect(name, 'Nothing'); | 62 expect(name, 'Nothing'); |
45 | 63 |
46 name = 'Foo'; | 64 name = 'Foo'; |
47 dispatch(); | 65 dispatch(); |
48 expect(foo.checked, true, reason: 'foo picked.'); | 66 expect(foo.checked, true, reason: 'foo picked.'); |
49 expect(bar.checked, false, reason: 'foo picked.'); | 67 expect(bar.checked, false, reason: 'foo picked.'); |
50 expect(name, 'Foo'); | 68 expect(name, 'Foo'); |
51 | 69 |
| 70 expect(foo.xtag.clicked, 0); |
| 71 expect(bar.xtag.clicked, 0); |
52 bar.on.click.dispatch( | 72 bar.on.click.dispatch( |
53 new MouseEvent('click', window, 1, 0, 0, 0, 0, 0)); | 73 new MouseEvent('click', window, 1, 0, 0, 0, 0, 0)); |
54 expect(name, 'Bar', reason: 'bar clicked.'); | 74 expect(name, 'Bar', reason: 'bar clicked.'); |
55 expect(foo.checked, false, reason: 'bar clicked.'); | 75 expect(foo.checked, false, reason: 'bar clicked.'); |
56 expect(bar.checked, true, reason: 'bar clicked.'); | 76 expect(bar.checked, true, reason: 'bar clicked.'); |
| 77 expect(foo.xtag.clicked, 0); |
| 78 expect(bar.xtag.clicked, 1); |
57 | 79 |
58 foo.checked = true; | 80 foo.checked = true; |
59 expect(bar.checked, false, reason: 'only one can be checked.'); | 81 expect(bar.checked, false, reason: 'only one can be checked.'); |
60 expect(foo.checked, true, reason: 'explicitly set this.'); | 82 expect(foo.checked, true, reason: 'explicitly set this.'); |
61 // It would be nice if this was "Foo". | 83 // It would be nice if this was "Foo". |
62 expect(name, 'Bar', reason: 'DOM checked does not fire event.'); | 84 expect(name, 'Bar', reason: 'DOM checked does not fire event.'); |
63 | 85 |
64 window.setTimeout(() => window.postMessage('done', '*'), 0); | 86 window.setTimeout(() => window.postMessage('done', '*'), 0); |
65 }, 0); | 87 }, 0); |
66 } | 88 } |
67 </script> | 89 </script> |
68 </body> | 90 </body> |
69 </html> | 91 </html> |
OLD | NEW |