From 66960d392fe7c52ab31aba21ad2863106e9ed4a3 Mon Sep 17 00:00:00 2001 From: bartvde Date: Tue, 9 Nov 2010 12:57:06 +0000 Subject: [PATCH] Filter strategy constructor should not need filter, r=tschaub,fredj (closes #2841) git-svn-id: http://svn.openlayers.org/trunk/openlayers@10879 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Strategy/Filter.js | 8 ++------ tests/Strategy/Filter.html | 10 +++++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Strategy/Filter.js b/lib/OpenLayers/Strategy/Filter.js index 3ade24a11d..51e86b1162 100644 --- a/lib/OpenLayers/Strategy/Filter.js +++ b/lib/OpenLayers/Strategy/Filter.js @@ -45,14 +45,10 @@ OpenLayers.Strategy.Filter = OpenLayers.Class(OpenLayers.Strategy, { * * Parameters: * options - {Object} Optional object whose properties will be set on the - * instance. Strategy must be constructed with at least a - * property. + * instance. */ initialize: function(options) { OpenLayers.Strategy.prototype.initialize.apply(this, [options]); - if (!this.filter || !(this.filter instanceof OpenLayers.Filter)) { - throw new Error("Filter strategy must be constructed with a filter"); - } }, /** @@ -102,7 +98,7 @@ OpenLayers.Strategy.Filter = OpenLayers.Class(OpenLayers.Strategy, { * Method: handleAdd */ handleAdd: function(event) { - if (!this.caching) { + if (!this.caching && this.filter) { var features = event.features; event.features = []; var feature; diff --git a/tests/Strategy/Filter.html b/tests/Strategy/Filter.html index 46a93ec37f..b88532af73 100644 --- a/tests/Strategy/Filter.html +++ b/tests/Strategy/Filter.html @@ -21,7 +21,7 @@ var filter = new OpenLayers.Filter.Comparison({ function test_initialize(t) { - t.plan(3); + t.plan(4); var strategy = new OpenLayers.Strategy.Filter({filter: filter}); @@ -31,6 +31,14 @@ function test_initialize(t) { t.ok(strategy.filter === filter, "has filter"); strategy.destroy(); + + try { + strategy = new OpenLayers.Strategy.Filter(); + t.ok(true, "strategy without filter works"); + } catch (err) { + t.fail("strategy without filter should not throw"); + } + }