Permalink
Browse files

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

…Mislav Marohnić]
  • Loading branch information...
1 parent 1a0f6b3 commit 194fda0b6d8277491c7766f1df3aa32031f4bb9f @madrobby madrobby committed Aug 17, 2007
Showing with 8 additions and 5 deletions.
  1. +2 −0 CHANGELOG
  2. +1 −1 src/array.js
  3. +2 −2 src/enumerable.js
  4. +3 −2 test/unit/enumerable.html
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) {

0 comments on commit 194fda0

Please sign in to comment.