Skip to content

Commit

Permalink
making canReflect.hasOwnKey work
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbmeyer committed Sep 5, 2018
1 parent 8b9ea3c commit ab9b443
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions can-simple-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var SimpleMap = Construct.extend("SimpleMap",
}
}
//!steal-remove-end

var dispatched = {
keyChanged: !had ? prop : undefined,
type: prop
Expand Down Expand Up @@ -203,7 +203,10 @@ var simpleMapProto = {
},
"can.getKeyDependencies": function(key) {
return undefined;
}
},
"can.hasOwnKey": function(key){
return this._data.hasOwnProperty(key);
}
};

//!steal-remove-start
Expand Down
9 changes: 9 additions & 0 deletions can-simple-map_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ QUnit.test("don't dispatch events for sets that don't change", 2, function(){
map.attr("foo","BAR");
});

QUnit.test("Reflect.hasOwnKey", function(){
var map = new SimpleMap({a: undefined, b: null, c: ""});

QUnit.ok( canReflect.hasOwnKey(map,"a"), "undefined is a key");
QUnit.ok( canReflect.hasOwnKey(map,"b"), "null is a key");
QUnit.ok( canReflect.hasOwnKey(map,"c"), "empty string is a key");
QUnit.ok( !canReflect.hasOwnKey(map,"d"), "no prop is not a key");
});

require("can-reflect-tests/observables/map-like/instance/on-get-set-delete-key")("", function(){
return new SimpleMap();
});

0 comments on commit ab9b443

Please sign in to comment.