documentcloud/underscore — Issue #345: _.include does not work when obj.indexOf is overridden (** showstopper)
Author: lprimak
Created: 2011-10-22 09:21:00+00:00
State: open

Basically, instead of if(found = value === target) return true,
it needs to be replaced by found = any(...)

Otherwise, if indexOf is overridden by another JS library,
the code does not work at all.

------------------- patch included ---------------
*** new/underscore_1_1_7.js	2011-10-22 05:10:36.000000000 -0400
--- old/underscore_1_1_7.js	2011-08-06 12:27:18.000000000 -0400
***************
*** 198,205 ****
var found = false;
if (obj == null) return found;
if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
! found = any(obj, function(value) {
! if (value === target) return true;
});
return found;
};
--- 198,205 ----
var found = false;
if (obj == null) return found;
if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
! any(obj, function(value) {
! if (found = value === target) return true;
});
return found;
};