Skip to content

Commit

Permalink
Merge pull request #107 from canjs/setup-triggers-keys
Browse files Browse the repository at this point in the history
not binding on __keys during setup
  • Loading branch information
phillipskevin committed Jul 19, 2018
2 parents c1dca96 + 9bdf7ae commit b8d18d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion can-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,9 @@ canReflect.assignSymbols(Map.prototype,{

// -shape
"can.getOwnEnumerableKeys": function(){
ObservationRecorder.add(this, '__keys');
if (!this.__inSetup) {
ObservationRecorder.add(this, '__keys');
}
var enumerable = this.constructor.enumerable;
if(enumerable) {
return Object.keys(this._data).filter(function(key){
Expand Down
14 changes: 14 additions & 0 deletions can-map_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,3 +524,17 @@ QUnit.test("attr should work when remove === 'true'", function(assert) {
assert.equal(canReflect.getKeyValue(map, 1), "one");
assert.equal(map.attr(1), "one");
});

QUnit.test("constructor should not bind on __keys (#106)", function(assert) {
var map;

var comp = canCompute(function() {
map = new Map();
});

canReflect.onValue(comp, function() {});

map.attr('foo', 'bar');

assert.equal(map.attr('foo'), 'bar', 'map should not be reset');
});

0 comments on commit b8d18d9

Please sign in to comment.