rh / lodash-rails

lodash for the Rails asset pipeline
MIT License
75 stars 10 forks source link

lodash.underscore _.contains() method returns false for all string values #3

Closed eggmatters closed 10 years ago

eggmatters commented 10 years ago

Version 2.4.0 appears to have a bug in the contains method. It returns false (for strings, untested with objects.) regardless of the values provided:

var test = _.contains('pebbles', 'eb');
>>> test: false

this line in contains evaluates to -1:

1769:  if (length && typeof length == 'number') {
1770:      result = indexOf(collection, target) > -1;
1771:  }

Where indexOf() is aliased to:

856: function getIndexOf() {
857:   var result = (result = lodash.indexOf) === indexOf ? baseIndexOf : result;
858:    return result;
859:  }

running the native method :

"pebbles".indexOf("eb")

returns true

rh commented 10 years ago

I updated Lo-Dash to 2.4.1, and I hope that solves it. If not, you could create an issue on the Lo-Dash project itself.

eggmatters commented 10 years ago

Thanks! Will do.