Skip to content

Commit

Permalink
Only consider own properties in Data.Hash.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael committed May 5, 2011
1 parent b261345 commit 4ead317
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@

// Get value at given *key*
get: function (key) {
return this.data[key];
return this.data.hasOwnProperty(key) ? this.data[key] : undefined;
},

// Get value at given *index*
Expand Down
11 changes: 11 additions & 0 deletions test/testsuite.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ test("Data.Hash#union", function() {
});


test("Only consider own properties", function() {
var hsh = new Data.Hash();

ok(hsh.get('toString') === undefined);
ok(hsh.get('toLocaleString') === undefined);
ok(hsh.get('watch') === undefined);
ok(hsh.get('hasOwnProperty') === undefined);
});



test("Data.Hash Events", function() {
persons = new Data.Hash();
persons.bind('set', function(key) { ok(key); });
Expand Down

0 comments on commit 4ead317

Please sign in to comment.