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 <script type="application/javascript" src="testing.js"></script> | 11 <script type="application/javascript" src="testing.js"></script> |
12 <style>x-greeter { display: block; }</style> | 12 <style>x-greeter { display: block; }</style> |
13 </head> | 13 </head> |
14 <body> | 14 <body> |
15 <element name="x-greeter" extends="div" constructor="Greeter"> | 15 <element name="x-greeter" extends="div" constructor="Greeter"> |
16 <template>{{greeting}}, {{name}}!</template> | 16 <template></template> |
17 <script type='application/dart'> | 17 <script type='application/dart'> |
18 import 'common.dart'; | |
19 import 'package:web_components/web_components.dart'; | 18 import 'package:web_components/web_components.dart'; |
20 class Greeter extends WebComponent { | 19 class Greeter extends WebComponent { |
21 String greeting, name; | 20 String greeting; |
| 21 changeStuff() { |
| 22 greeting = 'Yo dawg'; |
| 23 title = 'I heard you like $title so we put $title in yo $title.'; |
| 24 } |
22 } | 25 } |
23 </script> | 26 </script> |
24 </element> | 27 </element> |
25 <p> | 28 <p> |
26 This test has two loops, each over two items, for a total of four different | 29 The message changes from "hello world" to something more interesting. |
27 greeting messages: | |
28 </p> | 30 </p> |
29 <template iterate="g in greetings"> | 31 <!-- Note: "title" is a DOM field on all elements. |
30 <template iterate="n in names"> | 32 Also this element has no rendering. --> |
31 <x-greeter data-value="greeting:g, name:n"></x-greeter> | 33 <x-greeter id="greet" bind-title="data[1]" bind-greeting="data[0]"> |
32 </template> | 34 </x-greeter> |
33 </template> | 35 <p id="actual">{{data[0]}} {{data[1]}}</p> |
34 <script type="application/dart"> | 36 <script type="application/dart"> |
35 import 'dart:html'; | 37 import 'dart:html'; |
36 import 'package:unittest/unittest.dart'; | 38 import 'package:unittest/unittest.dart'; |
| 39 import 'package:web_components/web_components.dart'; |
37 | 40 |
38 var greetings = ['hello', 'hi']; | 41 var data = ['hello', 'world']; |
39 var names = ['world', 'universe']; | |
40 main() { | 42 main() { |
41 window.setTimeout(() { | 43 window.setTimeout(() { |
42 expect(query('x-greeter').attributes, equals({})); | 44 var actual = query('#actual'); |
| 45 var greet = query('#greet'); |
| 46 expect(actual.innerHTML, 'hello world'); |
| 47 greet.xtag.changeStuff(); |
| 48 dispatch(); |
| 49 expect(actual.innerHTML, contains('Yo dawg I heard')); |
43 window.postMessage('done', '*'); | 50 window.postMessage('done', '*'); |
44 }, 0); | 51 }, 0); |
45 } | 52 } |
46 </script> | 53 </script> |
47 </body> | 54 </body> |
48 </html> | 55 </html> |
OLD | NEW |