OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <!-- | 2 <!-- |
3 @license | 3 @license |
4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
5 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 5 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
8 Code distributed by Google as part of the polymer project is also | 8 Code distributed by Google as part of the polymer project is also |
9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
10 --> | 10 --> |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 331 |
332 test('empty menus don\'t unfocus themselves', function(done) { | 332 test('empty menus don\'t unfocus themselves', function(done) { |
333 var menu = fixture('empty'); | 333 var menu = fixture('empty'); |
334 | 334 |
335 menu.focus(); | 335 menu.focus(); |
336 Polymer.Base.async(function() { | 336 Polymer.Base.async(function() { |
337 assert.equal(Polymer.dom(document).activeElement, menu); | 337 assert.equal(Polymer.dom(document).activeElement, menu); |
338 done(); | 338 done(); |
339 }); | 339 }); |
340 }); | 340 }); |
| 341 |
| 342 test('`tabIndex` properties of all items are updated when items change',
function(done) { |
| 343 var menu = fixture('basic'); |
| 344 |
| 345 function assertTabIndexCounts(nodes, expected) { |
| 346 var tabIndexCounts = {}; |
| 347 for (var i = 0; i < nodes.length; i++) { |
| 348 var tabIndex = nodes[i].tabIndex; |
| 349 if (tabIndexCounts[tabIndex]) { |
| 350 tabIndexCounts[tabIndex]++; |
| 351 } else { |
| 352 tabIndexCounts[tabIndex] = 1; |
| 353 } |
| 354 } |
| 355 |
| 356 assert.equal(Object.keys(tabIndexCounts).length, Object.keys(expecte
d).length); |
| 357 Object.keys(expected).forEach(function(key) { |
| 358 assert.equal(tabIndexCounts[key], expected[key]); |
| 359 }); |
| 360 } |
| 361 |
| 362 function divWithTabIndex(tabIndex) { |
| 363 var div = document.createElement('div'); |
| 364 div.tabIndex = tabIndex; |
| 365 return div; |
| 366 } |
| 367 |
| 368 // Only the selected item will have tabIndex 0. |
| 369 menu.select(0); |
| 370 assertTabIndexCounts(menu.items, {"-1": 2, "0": 1}); |
| 371 |
| 372 Polymer.dom(menu).appendChild(divWithTabIndex(1)); |
| 373 Polymer.dom(menu).appendChild(divWithTabIndex(2)); |
| 374 Polymer.dom(menu).appendChild(divWithTabIndex(3)); |
| 375 |
| 376 // Async wait for `observeNodes`. |
| 377 Polymer.Base.async(function() { |
| 378 assertTabIndexCounts(menu.items, {"-1": 5, "0": 1}); |
| 379 done(); |
| 380 }); |
| 381 }); |
341 }); | 382 }); |
342 </script> | 383 </script> |
343 </body> | 384 </body> |
344 </html> | 385 </html> |
OLD | NEW |