Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: test/data/input/custom_radio_button_test.html

Issue 11416259: fix #136, support watch exprs and two way bindings for component fields (Closed) Base URL: https://github.com/dart-lang/dart-web-components.git@master
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/data/input/component_field_test.html ('k') | test/data/input/data_value_test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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>
OLDNEW
« no previous file with comments | « test/data/input/component_field_test.html ('k') | test/data/input/data_value_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698