OLD | NEW |
| (Empty) |
1 <!doctype html> | |
2 <!-- | |
3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | |
4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | |
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | |
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | |
7 Code distributed by Google as part of the polymer project is also | |
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | |
9 --> | |
10 <html> | |
11 <head> | |
12 <meta charset="UTF-8"> | |
13 <title>core-selector-template-repeat</title> | |
14 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-
scale=1.0"> | |
15 | |
16 <script src="../../platform/platform.js"></script> | |
17 <script src="../../web-component-tester/browser.js"></script> | |
18 | |
19 <link rel="import" href="../core-selector.html"> | |
20 | |
21 <style> | |
22 .core-selected { | |
23 background: #ccc; | |
24 } | |
25 </style> | |
26 | |
27 </head> | |
28 <body> | |
29 | |
30 <core-selector id="selector" selected="1"> | |
31 <template id="itemsTemplate" repeat="{{items}}"> | |
32 <div name="{{}}">{{}}</div> | |
33 </template> | |
34 </core-selector> | |
35 | |
36 <script> | |
37 | |
38 var s = document.querySelector('#selector'); | |
39 var t = document.querySelector('#itemsTemplate'); | |
40 | |
41 suite('<template repeat...>', function() { | |
42 | |
43 test('supports repeated children', function(done) { | |
44 t.model = {items: ['Item1', 'Item2', 'Item3', "Item4"]}; | |
45 asyncPlatformFlush(function() { | |
46 // check items | |
47 assert.equal(s.items.length, 4); | |
48 assert.equal(s.selected, 1); | |
49 // check selectedItem | |
50 var item = s.selectedItem; | |
51 assert.equal(s.items[1], item); | |
52 // check selected class | |
53 assert.isTrue(item.classList.contains('core-selected')); | |
54 done(); | |
55 }); | |
56 }); | |
57 | |
58 }); | |
59 | |
60 </script> | |
61 | |
62 </body> | |
63 </html> | |
OLD | NEW |