Skip to content

Commit

Permalink
Merge pull request #394 from canjs/393-retain-getter
Browse files Browse the repository at this point in the history
able to delete a key
  • Loading branch information
justinbmeyer committed Sep 24, 2018
2 parents e845796 + f76a0f3 commit ba24d71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion define-helpers/define-helpers.js
Expand Up @@ -91,7 +91,7 @@ var defineHelpers = {
var oldValue = this._data[prop];
if(oldValue !== undefined) {
delete this._data[prop];
delete this[prop];
//delete this[prop];
this.dispatch({
type: prop,
target: this,
Expand Down
19 changes: 15 additions & 4 deletions map/map-test.js
Expand Up @@ -9,6 +9,7 @@ var isPlainObject = canReflect.isPlainObject;
var canTestHelpers = require("can-test-helpers/lib/dev");
var DefineList = require("can-define/list/list");
var dev = require("can-log/dev/dev");
var ObservationRecorder = require("can-observation-recorder");

var sealWorks = (function() {
try {
Expand Down Expand Up @@ -1395,10 +1396,9 @@ QUnit.test("deleteKey works (#351)", function(){

map.deleteKey("foo");

var pd = Object.getOwnPropertyDescriptor(map, "foo");


QUnit.ok(!pd, "no property descriptor");
// We should keep the property descriptor
// var pd = Object.getOwnPropertyDescriptor(map, "foo");
// QUnit.ok(!pd, "no property descriptor");

QUnit.deepEqual( canReflect.getOwnKeys(map), [] );

Expand All @@ -1412,6 +1412,17 @@ QUnit.test("deleteKey works (#351)", function(){
QUnit.equal(map.foo, undefined, "prop set to undefined");
});

QUnit.test("makes sure observation add is called (#393)", function(){
var map = new DefineMap({foo: "bar"});

canReflect.deleteKeyValue(map, "foo");

ObservationRecorder.start();
(function(){ return map.foo; }());
var result = ObservationRecorder.stop();
QUnit.deepEqual(canReflect.toArray( result.keyDependencies.get(map) ), ["foo"], "toArray" );
});

QUnit.test("type called with `this` as the map (#349)", function(){
var Type = DefineMap.extend({
foo: {
Expand Down

0 comments on commit ba24d71

Please sign in to comment.