Making it so mergeWithDefaultFilter returns undefined if the protocol defaultFilter is falsey. r=ahocevar,me (closes #2796)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10658 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -57,20 +57,18 @@ OpenLayers.Protocol = OpenLayers.Class({
|
||||
* filter - {OpenLayers.Filter}
|
||||
*/
|
||||
mergeWithDefaultFilter: function(filter) {
|
||||
if(filter) {
|
||||
if(this.defaultFilter) {
|
||||
filter = new OpenLayers.Filter.Logical({
|
||||
type: OpenLayers.Filter.Logical.AND,
|
||||
filters: [this.defaultFilter, filter]
|
||||
});
|
||||
}
|
||||
var merged;
|
||||
if (filter && this.defaultFilter) {
|
||||
merged = new OpenLayers.Filter.Logical({
|
||||
type: OpenLayers.Filter.Logical.AND,
|
||||
filters: [this.defaultFilter, filter]
|
||||
});
|
||||
} else {
|
||||
filter = this.defaultFilter;
|
||||
merged = filter || this.defaultFilter || undefined;
|
||||
}
|
||||
return filter;
|
||||
return merged;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
* Clean up the protocol.
|
||||
|
||||
@@ -16,13 +16,22 @@
|
||||
}
|
||||
|
||||
function test_read_defaultFilter(t) {
|
||||
t.plan(3);
|
||||
t.plan(4);
|
||||
|
||||
var protocol = new OpenLayers.Protocol({filter: "a"});
|
||||
var options = {};
|
||||
protocol.read(options);
|
||||
// the line below is what happens in Protocol.WFS.v1::read
|
||||
OpenLayers.Util.applyDefaults(options, protocol.options);
|
||||
t.eq(options.filter, "a", "filter from protocol.options applied to options");
|
||||
protocol.destroy();
|
||||
|
||||
var defaultFilter = 'a';
|
||||
var options = {
|
||||
defaultFilter: defaultFilter
|
||||
};
|
||||
|
||||
var protocol = new OpenLayers.Protocol(options);
|
||||
protocol = new OpenLayers.Protocol(options);
|
||||
var readFilter = 'b';
|
||||
var options = { filter: readFilter };
|
||||
|
||||
@@ -32,6 +41,7 @@
|
||||
t.ok(filter instanceof OpenLayers.Filter.Logical, "read method merge default filter & options filter to a logical one");
|
||||
t.eq(filter.type, OpenLayers.Filter.Logical.AND, "logical filter type is OpenLayers.Filter.Logical.AND");
|
||||
t.eq(filter.filters, [defaultFilter, readFilter], "read method has merged filters");
|
||||
protocol.destroy();
|
||||
}
|
||||
|
||||
function test_destroy(t) {
|
||||
|
||||
Reference in New Issue
Block a user