Skip to content

Commit

Permalink
Add 'selectedItem' getter
Browse files Browse the repository at this point in the history
  • Loading branch information
grafluxe committed Dec 1, 2017
1 parent db02f38 commit de997aa
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Dropdownizer.js
Expand Up @@ -42,6 +42,16 @@ class Dropdownizer {
return this;
}

/**
* Gets informations of the currently selected list item(s).
* @type {Array|Object}
*/
get selectedItem() {
let selectedItems = this._dropdowns.map(dropdown => dropdown.selectedItem);

return (selectedItems.length > 1 ? selectedItems : selectedItems[0]);
}

/**
* Listens for change events.
* @param {Function} callback The callback function to execute when a list item changes.
Expand Down Expand Up @@ -342,6 +352,14 @@ class Dropdownize {
return out;
}

/**
* Gets informations of the currently selected list item.
* @type {Object}
*/
get selectedItem() {
return this._callbackArgs(this._listItems[this._lastSelectedIndex]);
}

/**
* Listens for change events.
* @param {Function} callback The callback function to execute when a list item changes.
Expand Down

0 comments on commit de997aa

Please sign in to comment.