OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // require: listselectionmodel.js | 5 // require: listselectionmodel.js |
6 | 6 |
7 /** | 7 /** |
8 * @fileoverview This implements a list control. | 8 * @fileoverview This implements a list control. |
9 */ | 9 */ |
10 | 10 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 var dataModel = this.dataModel; | 216 var dataModel = this.dataModel; |
217 if (dataModel) { | 217 if (dataModel) { |
218 return indexes.map(function(i) { | 218 return indexes.map(function(i) { |
219 return dataModel.item(i); | 219 return dataModel.item(i); |
220 }); | 220 }); |
221 } | 221 } |
222 return []; | 222 return []; |
223 }, | 223 }, |
224 | 224 |
225 /** | 225 /** |
226 * The HTML elements representing the items. This is just all the element | 226 * The HTML elements representing the items. This is just all the list item |
227 * children but subclasses may override this to filter out certain elements. | 227 * children but subclasses may override this to filter out certain elements. |
228 * @type {HTMLCollection} | 228 * @type {HTMLCollection} |
229 */ | 229 */ |
230 get items() { | 230 get items() { |
231 return this.children; | 231 var listItems = []; |
232 var children = this.children; | |
233 for (var i = 0; i < children.length; i++) { | |
234 var classList = children[i].classList; | |
235 if (classList && !classList.contains('spacer')) | |
arv (Not doing code reviews)
2010/12/15 04:15:28
classList should never be falsey
| |
236 listItems.push(children[i]); | |
237 } | |
238 return listItems; | |
arv (Not doing code reviews)
2010/12/15 04:15:28
How about:
return Array.prototype.filter.call(thi
| |
232 }, | 239 }, |
233 | 240 |
234 batchCount_: 0, | 241 batchCount_: 0, |
235 | 242 |
236 /** | 243 /** |
237 * When making a lot of updates to the list, the code could be wrapped in | 244 * When making a lot of updates to the list, the code could be wrapped in |
238 * the startBatchUpdates and finishBatchUpdates to increase performance. Be | 245 * the startBatchUpdates and finishBatchUpdates to increase performance. Be |
239 * sure that the code will not return without calling endBatchUpdates or the | 246 * sure that the code will not return without calling endBatchUpdates or the |
240 * list will not be correctly updated. | 247 * list will not be correctly updated. |
241 */ | 248 */ |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 } | 577 } |
571 } | 578 } |
572 }; | 579 }; |
573 | 580 |
574 cr.defineProperty(List, 'disabled', cr.PropertyKind.BOOL_ATTR); | 581 cr.defineProperty(List, 'disabled', cr.PropertyKind.BOOL_ATTR); |
575 | 582 |
576 return { | 583 return { |
577 List: List | 584 List: List |
578 } | 585 } |
579 }); | 586 }); |
OLD | NEW |