can-connect
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -10,2 +10,3 @@ var connect = require("can-connect/can-connect"); | ||
var DefineMap = require('can-define/map/'); | ||
require('can-define/list/list'); | ||
@@ -43,1 +44,47 @@ QUnit.module("can-connect/callbacks-once"); | ||
}); | ||
QUnit.test("different methods should not refer to the same last item", function(){ | ||
function Session(data){ | ||
this.id = data.id; | ||
this.email = data.email; | ||
} | ||
var createdCalled = 0; | ||
var destroyedCalled = 0; | ||
Session.connection = connect([ | ||
constructorStore, | ||
{ | ||
// simulate can/map/map's `id`: | ||
id: function(instance){ | ||
return instance.id; | ||
}, | ||
// simulate can/constructor/constructor: | ||
createdInstance: function(instance, data){ | ||
this.addInstanceReference(instance); | ||
createdCalled++; | ||
}, | ||
// simulate can/constructor/constructor: | ||
destroyedInstance: function(instance, data){ | ||
destroyedCalled++; | ||
} | ||
}, | ||
callbacksOnce | ||
], { | ||
Map: Session | ||
}); | ||
var data = { | ||
id: 100, | ||
email: 'ilya@bitovi.com' | ||
}; | ||
var instance = new Session(data); | ||
Session.connection.createdInstance(instance, data); | ||
Session.connection.createdInstance(instance, data); | ||
Session.connection.destroyedInstance(instance, data); | ||
Session.connection.destroyedInstance(instance, data); | ||
QUnit.equal(createdCalled, 1, "created event should be called once"); | ||
QUnit.equal(destroyedCalled, 1, "destroyed event should be called once"); | ||
}); |
@@ -61,9 +61,8 @@ /** | ||
var lastSerialized = this.getInstanceMetaData(instance, "last-data"); | ||
var lastSerialized = this.getInstanceMetaData(instance, "last-data-" + name); | ||
var serialize = sortedSetJSON(data), | ||
serialized = sortedSetJSON( this.serializeInstance( instance ) ); | ||
var serialize = sortedSetJSON(data); | ||
if(lastSerialized !== serialize) { | ||
var result = baseConnection[name].apply(this, arguments); | ||
this.addInstanceMetaData(instance, "last-data", serialize); | ||
this.addInstanceMetaData(instance, "last-data-" + name, serialize); | ||
return result; | ||
@@ -70,0 +69,0 @@ } |
{ | ||
"name": "can-connect", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "Data connection middleware and utilities", | ||
@@ -5,0 +5,0 @@ "main": "can-connect.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
483646
141
12701
0