prototype: Make sure Enumerable#include doesnt do type comparision. [Mislav Marohnić]

This commit is contained in:
Thomas Fuchs 2007-08-17 11:06:07 +00:00
parent 1a0f6b3f02
commit 194fda0b6d
4 changed files with 8 additions and 5 deletions

View File

@ -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 File

@ -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 File

@ -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 File

@ -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) {