Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

prototype: Make sure Enumerable#include doesnt do type comparision. […

…Mislav Marohnić]
  • Loading branch information...
commit 194fda0b6d8277491c7766f1df3aa32031f4bb9f 1 parent 1a0f6b3
@madrobby madrobby authored
View
2  CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Make sure Enumerable#include doesn't do type comparision. [Mislav Marohnić]
+
* Add contextmenu to Event.DOMEvents. [Thomas Fuchs]
*1.6.0_rc0* (August 15, 2007)
View
2  src/array.js
@@ -87,7 +87,7 @@ Object.extend(Array.prototype, {
intersect: function(array) {
return this.uniq().findAll(function(item) {
- return array.include(item);
+ return array.detect(function(value) { return item === value });
});
},
View
4 src/enumerable.js
@@ -89,11 +89,11 @@ var Enumerable = {
include: function(object) {
if (Object.isFunction(this.indexOf))
- return this.indexOf(object) != -1;
+ if (this.indexOf(object) != -1) return true;
var found = false;
this.each(function(value) {
- if (value === object) {
+ if (value == object) {
found = true;
throw $break;
}
View
5 test/unit/enumerable.html
@@ -199,9 +199,10 @@
testInclude: function() {with(this) {
assert(Fixtures.Nicknames.include('sam-'));
assert(Fixtures.Nicknames.include('noradio'));
- assert(Fixtures.Nicknames.include('htonl'));
- assert(Fixtures.Nicknames.include('Ulysses'));
assert(!Fixtures.Nicknames.include('gmosx'));
+ assert(Fixtures.Basic.include(2));
+ assert(Fixtures.Basic.include('2'));
+ assert(!Fixtures.Basic.include('4'));
}},
testInGroupsOf: function() { with(this) {
Please sign in to comment.
Something went wrong with that request. Please try again.