Skip to content

Commit

Permalink
Handle bad indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
sandersky committed Nov 1, 2016
1 parent 46cd199 commit b29bc82
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addon/components/frost-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ export default Component.extend(PropTypeMixin, {
}

if (typeOf(selected) === 'array') {
return selected.map((itemIndex) => items[itemIndex])
return selected
.filter((itemIndex) => itemIndex >= 0 && itemIndex < items.length)
.map((itemIndex) => items[itemIndex])
}

if (selected) {
if (selected ** selected <= 0 && selected < items.length) {
return [items[selected]]
}

Expand Down

0 comments on commit b29bc82

Please sign in to comment.