Merge pull request #896 from mosesonline/refresh-bugfix

Refresh bugfix
This commit is contained in:
ahocevar
2013-03-01 07:02:35 -08:00
2 changed files with 19 additions and 0 deletions

View File

@@ -79,6 +79,10 @@ OpenLayers.Strategy.Refresh = OpenLayers.Class(OpenLayers.Strategy, {
var deactivated = OpenLayers.Strategy.prototype.deactivate.call(this);
if(deactivated) {
this.stop();
this.layer.events.un({
"visibilitychanged": this.reset,
scope: this
});
}
return deactivated;
},

View File

@@ -31,6 +31,21 @@
"activates registers visibilitychanged listener");
}
function test_deactivate(t) {
t.plan(3);
var l = new OpenLayers.Layer.Vector();
l.setVisibility(false);
var s = new OpenLayers.Strategy.Refresh();
s.setLayer(l);
s.activate();
var deactivated = s.deactivate();
t.eq(deactivated, true, "deactivate returns true");
t.eq(s.active, false, "deactivated after activate");
t.ok(l.events.listeners.visibilitychanged.length == 0,
"deactivate unregisters visibilitychanged listener");
}
function test_activateWithVisibleLayer(t) {
t.plan(5);