OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 library polymer_elements.test.iron_list_test_helpers; | 4 library polymer_elements.test.iron_list_test_helpers; |
5 | 5 |
6 import 'dart:html'; | 6 import 'dart:html'; |
7 import 'dart:js'; | 7 import 'dart:js'; |
| 8 import 'package:polymer_elements/iron_list.dart'; |
8 import 'common.dart'; | 9 import 'common.dart'; |
9 | 10 |
10 JsFunction _matchesSelector = context['Polymer']['DomApi']['matchesSelector']; | 11 JsFunction _matchesSelector = context['Polymer']['DomApi']['matchesSelector']; |
11 | 12 |
12 Element findElementInList(container, selector) { | 13 Element findElementInList(container, selector) { |
13 var i = 0; | 14 var i = 0; |
14 var children = container._children; | 15 var children = container._children; |
15 for (; i < children.length; i++) { | 16 for (; i < children.length; i++) { |
16 if (children[i].nodeType == Node.ELEMENT_NODE && | 17 if (children[i].nodeType == Node.ELEMENT_NODE && |
17 _matchesSelector.apply([children[i], selector])) { | 18 _matchesSelector.apply([children[i], selector])) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 var listRect = list.getBoundingClientRect(); | 67 var listRect = list.getBoundingClientRect(); |
67 return document.elementFromPoint( | 68 return document.elementFromPoint( |
68 (listRect.left + 1).floor(), (listRect.top + 1).floor()); | 69 (listRect.left + 1).floor(), (listRect.top + 1).floor()); |
69 } | 70 } |
70 | 71 |
71 Element getLastItemFromList(list) { | 72 Element getLastItemFromList(list) { |
72 var listRect = list.getBoundingClientRect(); | 73 var listRect = list.getBoundingClientRect(); |
73 return document.elementFromPoint((listRect.left + 1).floor(), | 74 return document.elementFromPoint((listRect.left + 1).floor(), |
74 (listRect.top + listRect.height - 1).floor()); | 75 (listRect.top + listRect.height - 1).floor()); |
75 } | 76 } |
| 77 |
| 78 isFullOfItems(IronList list) { |
| 79 var listRect = list.getBoundingClientRect(); |
| 80 var listHeight = listRect.height - 1; |
| 81 var item, y = listRect.top + 1; |
| 82 // IE 10 & 11 doesn't render propertly :( |
| 83 var badPixels = 0; |
| 84 while (y < listHeight) { |
| 85 item = document.elementFromPoint((listRect.left + 1).floor(), y.floor()) |
| 86 as HtmlElement; |
| 87 if (item.parentNode != null && |
| 88 new JsObject.fromBrowserObject(item.parentNode)['_templateInstance'] == |
| 89 null) { |
| 90 badPixels++; |
| 91 } |
| 92 if (badPixels > 3) { |
| 93 return false; |
| 94 } |
| 95 y += 2; |
| 96 } |
| 97 return true; |
| 98 } |
OLD | NEW |