[OpenLayers-Commits] r11883 - in trunk/openlayers:
lib/OpenLayers/Protocol tests/Protocol
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Thu Apr 7 02:49:40 EDT 2011
Author: erilem
Date: 2011-04-06 23:49:38 -0700 (Wed, 06 Apr 2011)
New Revision: 11883
Modified:
trunk/openlayers/lib/OpenLayers/Protocol/HTTP.js
trunk/openlayers/tests/Protocol/HTTP.html
Log:
Protocol.HTTP.read should not write params into the protocol's options object, p=etdube,me r=me (closes #3237)
Modified: trunk/openlayers/lib/OpenLayers/Protocol/HTTP.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Protocol/HTTP.js 2011-04-06 22:06:31 UTC (rev 11882)
+++ trunk/openlayers/lib/OpenLayers/Protocol/HTTP.js 2011-04-07 06:49:38 UTC (rev 11883)
@@ -175,9 +175,10 @@
*/
read: function(options) {
OpenLayers.Protocol.prototype.read.apply(this, arguments);
- options = OpenLayers.Util.applyDefaults(options, this.options);
+ options = options || {};
options.params = OpenLayers.Util.applyDefaults(
options.params, this.options.params);
+ options = OpenLayers.Util.applyDefaults(options, this.options);
if (options.filter && this.filterToParams) {
options.params = this.filterToParams(
options.filter, options.params
Modified: trunk/openlayers/tests/Protocol/HTTP.html
===================================================================
--- trunk/openlayers/tests/Protocol/HTTP.html 2011-04-06 22:06:31 UTC (rev 11882)
+++ trunk/openlayers/tests/Protocol/HTTP.html 2011-04-07 06:49:38 UTC (rev 11883)
@@ -779,7 +779,7 @@
});
protocol.read();
- t.delay_call(1, function() {
+ t.delay_call(2, function() {
t.eq(log1.callbackCalled, true, "[read] callback called");
t.eq(log1.callbackScope, scope, "[read] correct scope");
t.ok(log1.request instanceof OpenLayers.Request.XMLHttpRequest, "[read] correct priv type");
@@ -801,11 +801,37 @@
{state: OpenLayers.State.DELETE, url: "./3"},
{state: OpenLayers.State.DELETE, url: "./4"}
]);
- t.delay_call(1, function() {
+ t.delay_call(2, function() {
t.eq(log2.called, 1, "[commit] Callback called once.");
t.eq(log2.scope, scope, "[commit] Correct scope.");
});
+ }
+ function test_read_global_options(t) {
+
+ // test that calling read doesn't write params into the protocol's
+ // options object, see ticket #3237
+
+ t.plan(2);
+
+ var protocol = new OpenLayers.Protocol.HTTP({
+ url: '.',
+ callback: function() {},
+ params: {'a': 'a'}
+ });
+
+ // check initial state first
+ t.eq(protocol.options.params, {'a': 'a'},
+ 'protocol params are ok at initial state');
+
+ var filter = new OpenLayers.Filter.Comparison({
+ type: OpenLayers.Filter.Comparison.EQUAL_TO,
+ property: 'b',
+ value: 'b'
+ });
+ protocol.read({filter: filter});
+ t.eq(protocol.options.params, {'a': 'a'},
+ "protocol params are ok after read");
}
More information about the Commits
mailing list