Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions can-define.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ define.makeDefineInstanceKey = function(constructor) {
}

this.prototype.dispatch({
type: "can.keys",
action: "can.keys",
type: "can.keys", // TODO: Remove in 6.0
target: this.prototype
});
};
Expand Down Expand Up @@ -470,8 +471,12 @@ make = {
computeObj.oldValue = newVal;

map.dispatch({
type: prop,
target: map
action: "set",
key: "prop",
target: map,
value: newVal,
oldValue: oldValue,
type: prop, // TODO: Remove in 6.0
}, [newVal, oldValue]);
}
};
Expand Down Expand Up @@ -547,11 +552,15 @@ make = {
var dispatched;
setData.call(this, newVal);

dispatched = {
patches: [{type: "set", key: prop, value: newVal}],
type: prop,
target: this
};
dispatched = {
patches: [{type: "set", key: prop, value: newVal}],
target: this,
action: "set",
value: newVal,
oldValue: current,
key: prop,
type: prop // TODO: Remove in 6.0
};

//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
Expand Down Expand Up @@ -1141,13 +1150,18 @@ define.expando = function(map, prop, value) {
if(!map[inSetupSymbol]) {
queues.batch.start();
map.dispatch({
type: "can.keys",
target: map
action: "can.keys",
target: map,
type: "can.keys" // TODO: Remove in 6.0
});
if(Object.prototype.hasOwnProperty.call(map._data, prop)) {
map.dispatch({
type: prop,
action: "add",
target: map,
value: map._data[prop],
oldValue: undefined,
key: prop,
type: prop, // TODO: Remove in 6.0
patches: [{type: "add", key: prop, value: map._data[prop]}],
},[map._data[prop], undefined]);
} else {
Expand Down
9 changes: 7 additions & 2 deletions define-helpers/define-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,20 @@ var defineHelpers = {
delete instanceDefines[prop];
queues.batch.start();
this.dispatch({
type: "can.keys",
action: "can.keys",
type: "can.keys", // TODO: Remove in 6.0
target: this
});
var oldValue = this._data[prop];
if(oldValue !== undefined) {
delete this._data[prop];
//delete this[prop];
this.dispatch({
type: prop,
action: "delete",
key: prop,
value: undefined,
oldValue: oldValue,
type: prop, // TODO: Remove in 6.0
target: this,
patches: [{type: "delete", key: prop}],
},[undefined,oldValue]);
Expand Down
9 changes: 8 additions & 1 deletion list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ var DefineList = Construct.extend("DefineList",
patches = [{type: "splice", insert: newVal, index: index, deleteCount: 0}];
dispatched = {
type: how,
action: "splice",
insert: newVal,
index: index,
deleteCount: 0,
patches: patches
};

Expand All @@ -148,7 +152,10 @@ var DefineList = Construct.extend("DefineList",
patches = [{type: "splice", index: index, deleteCount: oldVal.length}];
dispatched = {
type: how,
patches: patches
patches: patches,
action: "splice",
index: index, deleteCount: oldVal.length,
target: this
};
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
Expand Down
6 changes: 5 additions & 1 deletion map/map-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ canTestHelpers.devOnlyTest("can.hasKey and can.hasOwnKey (#303) (#412)", functio
assert.equal(vm[hasOwnKeySymbol]("parentDerivedProp"), false, "vm.hasOwnKey('parentDerivedProp') false");

assert.equal(vm[hasOwnKeySymbol]("anotherProp"), false, "vm.hasOwnKey('anotherProp') false");

var map = new DefineMap({expandoKey: undefined});
assert.equal(map[hasKeySymbol]("expandoKey"), true, "map.hasKey('expandoKey') (#412)");
});
Expand Down Expand Up @@ -1633,3 +1633,7 @@ QUnit.test("'*' wildcard type definitions that use DefineMap constructors works
var foo = map.get( "foo" );
assert.ok(foo instanceof MyType);
});

require("can-reflect-tests/observables/map-like/instance/on-event-get-set-delete-key")("DefineMap", function(){
return new DefineMap();
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"can-symbol": "^1.0.0"
},
"devDependencies": {
"can-reflect-tests": "<0.3.0",
"can-reflect-tests": "^1.0.0",
"can-test-helpers": "^1.1.4",
"detect-cyclic-packages": "^1.1.0",
"jshint": "^2.9.1",
Expand Down