1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 cr.define('cr.ui', function() {
8 * Creates a new list item element.
9 * @param {string} opt_label The text label for the item.
11 * @extends {HTMLLIElement}
13 var ListItem = cr.ui.define('li');
15 ListItem.prototype = {
16 __proto__: HTMLLIElement.prototype,
23 return this.textContent;
26 this.textContent = label;
30 * This item's index in the containing list.
36 * Called when an element is decorated as a list item.
38 decorate: function() {
39 this.setAttribute('role', 'listitem');
43 * Called when the selection state of this element changes.
45 selectionChanged: function() {
50 * Whether the item is selected. Setting this does not update the underlying
51 * selection model. This is only used for display purpose.
54 cr.defineProperty(ListItem, 'selected', cr.PropertyKind.BOOL_ATTR,
56 this.selectionChanged();
60 * Whether the item is the lead in a selection. Setting this does not update
61 * the underlying selection model. This is only used for display purpose.
64 cr.defineProperty(ListItem, 'lead', cr.PropertyKind.BOOL_ATTR);
67 * This item's index in the containing list.
70 cr.defineProperty(ListItem, 'listIndex');