Skip to content

Commit 9f45c74

Browse files
committed
~DOP mutations only are applyed if an array is already defined.
1 parent 3fa1c28 commit 9f45c74

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/core/objects/setAction.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ dop.core.setActionMutator = function(destiny, prop, value, typeofValue, path) {
1111
var typeofDestiny = dop.util.typeof(destiny[prop]);
1212

1313
// Array mutations
14-
if (typeofValue=='object' && value.hasOwnProperty(dop.cons.DOP)) {
14+
if (typeofValue=='object' && typeofDestiny=='array' && value.hasOwnProperty(dop.cons.DOP)) {
1515

1616
var mutations = value[dop.cons.DOP],
1717
mutation,
1818
index=0,
1919
total=mutations.length;
2020

21-
if (typeofDestiny!='array')
22-
dop.set(destiny, prop, []);
21+
// if (typeofDestiny!='array')
22+
// dop.set(destiny, prop, []);
2323

2424
for (;index<total; ++index) {
2525
mutation = mutations[index];

test/transports/unsubscribe.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ test('Client unsubscribe Server', function(t) {
3939

4040
client.unsubscribe(objectClient)
4141
.then(function(){
42+
t.deepEqual(dopServer.data.object[1], undefined, 'Object in server removed from data.object');
43+
t.deepEqual(dopServer.data.object[7], undefined, 'Object in client removed from data.object');
4244
t.deepEqual(objectDataServer.node[serverClient.token].subscriber, 0, 'Client is not subscriber');
4345
t.deepEqual(objectDataServer.node[serverClient.token].owner, 0, 'Client is not owner');
4446
t.deepEqual(objectDataClient.node[client.token].subscriber, 0, 'Server is not subscriber');
@@ -51,4 +53,4 @@ test('Client unsubscribe Server', function(t) {
5153
t.end();
5254
})
5355

54-
})
56+
})

0 commit comments

Comments
 (0)