diff --git a/CHANGELOG b/CHANGELOG index 07bb563..c580428 100644 --- a/CHANGELOG +++ b/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) diff --git a/src/array.js b/src/array.js index 89b6831..db192be 100644 --- a/src/array.js +++ b/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 }); }); }, diff --git a/src/enumerable.js b/src/enumerable.js index 2b2ae06..50d09d2 100644 --- a/src/enumerable.js +++ b/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; } diff --git a/test/unit/enumerable.html b/test/unit/enumerable.html index 064f247..982d40c 100644 --- a/test/unit/enumerable.html +++ b/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) {