[OpenLayers-Commits] r7350 - sandbox/camptocamp/unhcr/lib/OpenLayers/Protocol
commits at openlayers.org
commits at openlayers.org
Wed Jun 11 10:07:51 EDT 2008
Author: elemoine
Date: 2008-06-11 10:07:51 -0400 (Wed, 11 Jun 2008)
New Revision: 7350
Modified:
sandbox/camptocamp/unhcr/lib/OpenLayers/Protocol/HTTP.js
Log:
avoid copying options twice, user must not reuse the object
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Protocol/HTTP.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Protocol/HTTP.js 2008-06-11 13:48:50 UTC (rev 7349)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Protocol/HTTP.js 2008-06-11 14:07:51 UTC (rev 7350)
@@ -108,13 +108,13 @@
*
* Parameters:
* options - {Object} Optional object for configuring the request.
+ * This object is modified and should not be reused.
*/
'read': function(options) {
- var mergedOptions = OpenLayers.Util.extend({}, options);
- OpenLayers.Util.applyDefaults(mergedOptions, this.options);
+ options = OpenLayers.Util.applyDefaults(options, this.options);
var callback = function(request) {
- if(mergedOptions.callback) {
+ if(options.callback) {
var resp = new OpenLayers.Protocol.Response({
'priv': request,
'features': null
@@ -128,17 +128,17 @@
resp.code = OpenLayers.Protocol.Response.FAILURE;
}
- mergedOptions.callback.call(
- mergedOptions.scope, resp
+ options.callback.call(
+ options.scope, resp
);
}
};
return OpenLayers.Request.GET({
- url: mergedOptions.url,
+ url: options.url,
callback: callback,
- params: mergedOptions.params,
- headers: mergedOptions.headers,
+ params: options.params,
+ headers: options.headers,
scope: this
});
},
@@ -151,13 +151,13 @@
* features - {Array({<OpenLayers.Feature.Vector>})} or
* {<OpenLayers.Feature.Vector>}
* options - {Object} Optional object for configuring the request.
+ * This object is modified and should not be reused.
*/
'create': function(features, options) {
- var mergedOptions = OpenLayers.Util.extend({}, options);
- OpenLayers.Util.applyDefaults(mergedOptions, this.options);
+ options = OpenLayers.Util.applyDefaults(options, this.options);
var callback = function(request) {
- if(mergedOptions.callback) {
+ if(options.callback) {
var resp = new OpenLayers.Protocol.Response({
'priv': request,
'features': null,
@@ -172,16 +172,16 @@
resp.code = OpenLayers.Protocol.Response.FAILURE;
}
- mergedOptions.callback.call(
- mergedOptions.scope, resp
+ options.callback.call(
+ options.scope, resp
);
}
};
return OpenLayers.Request.POST({
- url: mergedOptions.url,
+ url: options.url,
callback: callback,
- headers: mergedOptions.headers,
+ headers: options.headers,
data: this.format.write(features),
scope: this
});
@@ -195,14 +195,14 @@
* features - {Array({<OpenLayers.Feature.Vector>})} or
* {<OpenLayers.Feature.Vector>}
* options - {Object} Optional object for configuring the request.
+ * This object is modified and should not be reused.
*/
'update': function(features, options) {
var url = options.url || features.url || this.options.url;
- var mergedOptions = OpenLayers.Util.extend({}, options);
- OpenLayers.Util.applyDefaults(mergedOptions, this.options);
+ options = OpenLayers.Util.applyDefaults(options, this.options);
var callback = function(request) {
- if(mergedOptions.callback) {
+ if(options.callback) {
var resp = new OpenLayers.Protocol.Response({
'priv': request,
'features': null,
@@ -216,8 +216,8 @@
// failure
resp.code = OpenLayers.Protocol.Response.FAILURE;
}
- mergedOptions.callback.call(
- mergedOptions.scope, resp
+ options.callback.call(
+ options.scope, resp
);
}
};
@@ -225,7 +225,7 @@
return OpenLayers.Request.PUT({
url: url,
callback: callback,
- headers: mergedOptions.headers,
+ headers: options.headers,
data: this.format.write(features),
scope: this
});
@@ -238,14 +238,14 @@
* Parameters:
* feature - {<OpenLayers.Feature.Vector>}
* options - {Object} Optional object for configuring the request.
+ * This object is modified and should not be reused.
*/
'delete': function(feature, options) {
var url = options.url || feature.url;
- var mergedOptions = OpenLayers.Util.extend({}, options);
- OpenLayers.Util.applyDefaults(mergedOptions, this.options);
+ options = OpenLayers.Util.applyDefaults(options, this.options);
var callback = function(request) {
- if(mergedOptions.callback) {
+ if(options.callback) {
var resp = new OpenLayers.Protocol.Response({
'priv': request,
'features': null,
@@ -258,8 +258,8 @@
// failure
resp.code = OpenLayers.Protocol.Response.FAILURE;
}
- mergedOptions.callback.call(
- mergedOptions.scope, resp
+ options.callback.call(
+ options.scope, resp
);
}
};
@@ -267,7 +267,7 @@
return OpenLayers.Request.DELETE({
url: url,
callback: callback,
- headers: mergedOptions.headers,
+ headers: options.headers,
scope: this
});
},
@@ -281,7 +281,8 @@
* Parameters:
* features - {Array({<OpenLayers.Feature.Vector>})}
* options - {Object} Map of options, the keys of the map are
- * 'create', 'update', and 'delete'
+ * 'create', 'update', and 'delete'.
+ * This object is modified and should not be reused.
*
* Returns:
* {Integer} - The number of create/update/delete operations,
@@ -289,8 +290,7 @@
* when commit is done
*/
commit: function(features, options) {
- var mergedOptions = OpenLayers.Util.extend({}, options);
- OpenLayers.Util.applyDefaults(mergedOptions, this.options);
+ options = OpenLayers.Util.applyDefaults(options, this.options);
var numOps = 0;
var toCreate = [];
@@ -302,17 +302,17 @@
break;
case OpenLayers.State.UPDATE:
numOps++;
- this.update(feature, mergedOptions.update);
+ this.update(feature, options.update);
break;
case OpenLayers.State.DELETE:
numOps++;
- this["delete"](feature, mergedOptions["delete"]);
+ this["delete"](feature, options["delete"]);
break;
}
}
if (toCreate.length > 0) {
numOps++;
- this.create(toCreate, mergedOptions.create);
+ this.create(toCreate, options.create);
}
return numOps;
},
More information about the Commits
mailing list