Skip to content

Commit

Permalink
[Bugfix beta] map.has where map.length === 0 should return false not …
Browse files Browse the repository at this point in the history
…undefined.
  • Loading branch information
stefanpenner committed Oct 2, 2014
1 parent e280dc6 commit 63df972
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/ember-metal/lib/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ OrderedSet.prototype = {
@return {Boolean}
*/
has: function(obj) {
if (this.size === 0) { return; }
if (this.size === 0) { return false; }

var guid = guidFor(obj);
var presenceSet = this.presenceSet;
Expand Down Expand Up @@ -372,7 +372,7 @@ Map.prototype = {
@return {Boolean} true if the item was present, false otherwise
*/
has: function(key) {
if (this.size === 0) { return; }
if (this.size === 0) { return false; }
return this.keys.has(key);
},

Expand Down
5 changes: 5 additions & 0 deletions packages/ember-metal/tests/map_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ function testMap(nameAndFunc) {
mapHasEntries([]);
});

test("has empty collection", function() {
equal(map.has('foo'), false);
equal(map.has(), false);
});

test("delete", function() {
expectNoDeprecation();

Expand Down

0 comments on commit 63df972

Please sign in to comment.