Skip to content

Commit

Permalink
Remove findIndex polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
banderson committed Jul 26, 2017
1 parent 1059b23 commit 6558b1e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
25 changes: 1 addition & 24 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,6 @@ function stringifyValue (value) {
}
}

if (!Array.prototype.findIndex) {
Array.prototype.findIndex = function(predicate) {
if (this === null) {
throw new TypeError('Array.prototype.findIndex called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;

for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return i;
}
}
return -1;
};
}

const stringOrNode = PropTypes.oneOfType([
PropTypes.string,
PropTypes.node
Expand Down Expand Up @@ -544,7 +521,7 @@ class Select extends React.Component {
focusedIndex: null
}, () => {
var valueArray = this.getValueArray(this.props.value);
if (valueArray.find(i => i[this.props.valueKey] === value[this.props.valueKey])) {
if (valueArray.some(i => i[this.props.valueKey] === value[this.props.valueKey])) {
this.removeValue(value);
} else {
this.addValue(value);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/defaultMenuRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function menuRenderer ({
let Option = optionComponent;

return options.map((option, i) => {
let isSelected = valueArray && valueArray.findIndex(x => x[valueKey] == option[valueKey]) > -1;
let isSelected = valueArray && valueArray.some(x => x[valueKey] == option[valueKey]);
let isFocused = option === focusedOption;
let optionClass = classNames(optionClassName, {
'Select-option': true,
Expand Down

0 comments on commit 6558b1e

Please sign in to comment.