Protocol.HTTP.read should not write params into the protocol's options object, p=etdube,me r=me (closes #3237)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11883 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -175,9 +175,10 @@ OpenLayers.Protocol.HTTP = OpenLayers.Class(OpenLayers.Protocol, {
|
|||||||
*/
|
*/
|
||||||
read: function(options) {
|
read: function(options) {
|
||||||
OpenLayers.Protocol.prototype.read.apply(this, arguments);
|
OpenLayers.Protocol.prototype.read.apply(this, arguments);
|
||||||
options = OpenLayers.Util.applyDefaults(options, this.options);
|
options = options || {};
|
||||||
options.params = OpenLayers.Util.applyDefaults(
|
options.params = OpenLayers.Util.applyDefaults(
|
||||||
options.params, this.options.params);
|
options.params, this.options.params);
|
||||||
|
options = OpenLayers.Util.applyDefaults(options, this.options);
|
||||||
if (options.filter && this.filterToParams) {
|
if (options.filter && this.filterToParams) {
|
||||||
options.params = this.filterToParams(
|
options.params = this.filterToParams(
|
||||||
options.filter, options.params
|
options.filter, options.params
|
||||||
|
|||||||
@@ -779,7 +779,7 @@
|
|||||||
});
|
});
|
||||||
protocol.read();
|
protocol.read();
|
||||||
|
|
||||||
t.delay_call(1, function() {
|
t.delay_call(2, function() {
|
||||||
t.eq(log1.callbackCalled, true, "[read] callback called");
|
t.eq(log1.callbackCalled, true, "[read] callback called");
|
||||||
t.eq(log1.callbackScope, scope, "[read] correct scope");
|
t.eq(log1.callbackScope, scope, "[read] correct scope");
|
||||||
t.ok(log1.request instanceof OpenLayers.Request.XMLHttpRequest, "[read] correct priv type");
|
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: "./3"},
|
||||||
{state: OpenLayers.State.DELETE, url: "./4"}
|
{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.called, 1, "[commit] Callback called once.");
|
||||||
t.eq(log2.scope, scope, "[commit] Correct scope.");
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user