Chromium Code Reviews| Index: chrome/browser/resources/shared/js/cr/ui/list_item.js |
| diff --git a/chrome/browser/resources/shared/js/cr/ui/list_item.js b/chrome/browser/resources/shared/js/cr/ui/list_item.js |
| index 283216f9b2bea2e217d9d83f64683ae00585f060..11a8de33aed4ca82bfb22e124cbd94ae2df95f05 100644 |
| --- a/chrome/browser/resources/shared/js/cr/ui/list_item.js |
| +++ b/chrome/browser/resources/shared/js/cr/ui/list_item.js |
| @@ -27,10 +27,38 @@ cr.define('cr.ui', function() { |
| }, |
| /** |
| + * The current selection state. |
| + * @type {Boolean} |
| + */ |
| + get selected() { |
| + return this.hasAttribute('selected'); |
| + }, |
| + set selected(selected) { |
| + selected = Boolean(selected); |
|
arv (Not doing code reviews)
2010/12/17 21:48:19
The reason for the Boolean case is so that the tes
|
| + var oldSelected = this.selected; |
| + if (oldSelected == selected) |
| + return; |
| + |
| + if (selected) |
| + this.setAttribute('selected', ''); |
| + else |
| + this.removeAttribute('selected'); |
| + |
| + cr.dispatchPropertyChange(this, 'selected', selected, oldSelected); |
| + this.selectionChanged(); |
| + }, |
| + |
| + /** |
| * Called when an element is decorated as a list item. |
| */ |
| decorate: function() { |
| - } |
| + }, |
| + |
| + /** |
| + * Called when the selection state of this element changes. |
| + */ |
| + selectionChanged: function() { |
| + }, |
| }; |
| /** |