|
| 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.github.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/CONTRIBUTORS.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/PATENTS.txt |
| 9 | +--> |
| 10 | +<html> |
| 11 | +<head> |
| 12 | + <title>core-list</title> |
| 13 | + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> |
| 14 | + <script src="../../../platform/platform.js"></script> |
| 15 | + <link rel="import" href="../../../polymer-test-tools/ci-tools.html"> |
| 16 | + <link rel="import" href="../../core-list.html"> |
| 17 | + <style> |
| 18 | + html, body { |
| 19 | + margin: 0; |
| 20 | + -webkit-tap-highlight-color: transparent; |
| 21 | + overflow: hidden; |
| 22 | + } |
| 23 | + core-list { |
| 24 | + display: block; |
| 25 | + height: 100%; |
| 26 | + margin: 0 auto; |
| 27 | + } |
| 28 | + </style> |
| 29 | +</head> |
| 30 | +<body fit> |
| 31 | + |
| 32 | +<core-list id="list"> |
| 33 | + <template> |
| 34 | + <div class="item {{ {selected: selected} | tokenList }}"> |
| 35 | + <div class="subject">Row: {{index}}, Record ID: {{model.id}}</div> |
| 36 | + <input type="checkbox" checked="{{model.checked}}"> |
| 37 | + <input type="number" value="{{model.value}}" class="narrow"> |
| 38 | + <select selectedIndex="{{model.type}}"><option>a</option><option>b</option><option>c</option></select> |
| 39 | + </div> |
| 40 | + </template> |
| 41 | +</core-list> |
| 42 | + |
| 43 | +<script> |
| 44 | + document.addEventListener('polymer-ready', function() { |
| 45 | + // Test a property |
| 46 | + var el = document.querySelector('core-list'); |
| 47 | + el.data = [ |
| 48 | + {id:123, checked:true, value:99, type:1}, |
| 49 | + {id:456, checked:false, value:88, type:2} |
| 50 | + ]; |
| 51 | + el.onMutation(el, function() { |
| 52 | + el.data.length = 1; |
| 53 | + requestAnimationFrame(function() { |
| 54 | + chai.assert(el.children.length == 2 + 1, |
| 55 | + 'children.length should be 1 (template) + count of data elements'); |
| 56 | + chai.assert(el.children[el.children.length-1].getAttribute('hidden') !== null, |
| 57 | + 'last element shoudl be hidden'); |
| 58 | + done(); |
| 59 | + }); |
| 60 | + }); |
| 61 | + |
| 62 | + }); |
| 63 | + |
| 64 | +</script> |
| 65 | + |
| 66 | +</body> |
| 67 | +</html> |
0 commit comments